CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Nov 2009
    Location
    California
    Posts
    31

    page is invisible but no errors (firefox problem)

    i know the problem has something to do with the javascript but i cant find any errors.
    in the heading i load the script file
    Code:
    <script type='text/javascript' language='javascript' src='authinfobox.js' />
    Now in other browsers the page loads perfectly and everything shows up but in firefox nothing
    is visible. When i remove that line above, everything shows up. below is the code for the
    javascript file.
    Code:
    var boxshowing = false;
    
    function showAuthBox(authName, authAge, authLoc, index)
    {
        //1st check if an author info box is already showing
        //if it is call hide function which also removes the info
        if (boxshowing) hideAuthBox();
        //get top position of (empty) authname div element
        var nboxTop = document.getElementById("authnamebox["+index+"]").offsetTop;
        //get top pos of its parent element, add together to get best
        //positioning
        var parentTop = document.getElementById('apps_parent').offsetTop;
        //set the left position
        var lpos = document.getElementById("authnamebox["+index+"]").offsetLeft;
        var aib = document.getElementById('authinfobox');
        aib.style.left = lpos+"px";
        aib.style.top = nboxTop+parentTop+"px";
        //create necessary html elements to display the data
        var tmpdiv = document.createElement("div");
        tmpdiv.setAttribute("id", "tmpdiv");
        var txtNode = document.createTextNode("Name: "+authName);
        tmpdiv.appendChild(txtNode);
        //make line break
        var br = document.createElement("br");
        tmpdiv.appendChild(br);
        txtNode = document.createTextNode("Age: "+authAge);
        tmpdiv.appendChild(txtNode);
        //found that you must call createelement each time
        //for every <br> element created
        br = document.createElement("br");
        tmpdiv.appendChild(br);
        txtNode = document.createTextNode("Location: "+authLoc);
        tmpdiv.appendChild(txtNode);
        br = document.createElement("br");
        tmpdiv.appendChild(br);
        br = document.createElement("br");
        tmpdiv.appendChild(br);
        //create link to close box
        var htmlnode = document.createElement("a");
        htmlnode.setAttribute("href", "#");
        htmlnode.setAttribute("class", "closeauthbox");
        htmlnode.setAttribute("onclick", "hideAuthBox()");
        txtNode = document.createTextNode("close");
        htmlnode.appendChild(txtNode);
        tmpdiv.appendChild(htmlnode);
        //add tmpdiv to authinfobox
        aib.appendChild(tmpdiv);
        //make it visible!
        aib.style.display = "block";
        boxshowing = true;
    }
    
    function hideAuthBox()
    {
        //get handle to authinfobox
        var aib = document.getElementById('authinfobox');
        //make it invisible
        aib.style.display = "none";
        //remove inner div that contains the info
        var innerDiv = document.getElementById('tmpdiv');
        aib.removeChild(innerDiv);
        boxshowing = false;
    }

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    Re: page is invisible but no errors (firefox problem)

    Just supplying the JavaScript puts a lot of work on us to try to see the code in action. Why don't you upload us a full sample?
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Nov 2009
    Location
    California
    Posts
    31

    Re: page is invisible but no errors (firefox problem)

    here are the 3 files i use (php/css/javascript)
    Attached Files Attached Files

  4. #4
    Join Date
    May 2002
    Posts
    10,943

    Re: page is invisible but no errors (firefox problem)

    Almost...Instead of attaching the PHP page which references the MySQL database, can you please attach an outputted HTML example?

    And, have you checked Firefox's Error Console?
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  5. #5
    Join Date
    Nov 2009
    Location
    California
    Posts
    31

    Re: page is invisible but no errors (firefox problem)

    i've attached a txt file which is the outputted source. and yes, i used firebug to see if i could find an error but no errors showed up.
    Attached Files Attached Files

  6. #6
    Join Date
    May 2002
    Posts
    10,943

    Re: page is invisible but no errors (firefox problem)

    I'm sorry, I should have seen it before...you've invalidly terminated the script tag. Use the following instead.

    Code:
    <script type='text/javascript' src='authinfobox.js'></script>
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  7. #7
    Join Date
    Nov 2009
    Location
    California
    Posts
    31

    Re: page is invisible but no errors (firefox problem)

    Thank you sooo much!! I'm curious though, I've never read anything about it acting that way,
    because isn't that proper xhtml when I close it out that way?

  8. #8
    Join Date
    May 2002
    Posts
    10,943

    Re: page is invisible but no errors (firefox problem)

    Firefox is famous for not rendering anything of an HTML tag is incorrect within the <head> section.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured