Results 1 to 4 of 4

Thread: Problem with making a hidden layer visible in Firefox

  1. #1
    Join Date
    May 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Problem with making a hidden layer visible in Firefox

    I am using the following script to hide/unhide a layer in a site that I am building:

    Code:
    function hidediv() { 
    if (document.getElementById) { // DOM3 = IE5, NS6 
    document.getElementById('form1POP').style.visibility = 'hidden'; 
    } 
    else { 
    if (document.layers) { // Netscape 4 
    document.hideShow.visibility = 'hidden'; 
    } 
    else { // IE 4 
    document.all.hideShow.style.visibility = 'hidden'; 
    } 
    } 
    } 
    
    function showdiv() { 
    if (document.getElementById) { // DOM3 = IE5, NS6 
    document.getElementById('form1POP').style.visibility = 'visible'; 
    } 
    else { 
    if (document.layers) { // Netscape 4 
    document.hideShow.visibility = 'visible'; 
    } 
    else { // IE 4 
    document.all.hideShow.style.visibility = 'visible'; 
    } 
    } 
    }
    It works perfectly in IE6, IE7, and Opera (though in Opera the opacity isn't working but that is fine) But when I click on the button using Firefox the layer does not become visible. Can anyone help me out, this is on a short deadline...

    Many thanks

    JF

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Code:
    function showElement(id, w) {
      (document.getElementById(id) || document.all[id]).style.visibility = ((typeof w !== "undefined" && !w) ? "hidden" : "");
    }
    Usage:
    Code:
    showElement("form1POP", false); // Hide form1POP
    showElement("form1POP"); // Show form1POP
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    May 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for the reply Twey, I placed the script you provided in my .js file, and added the function info you placed underneath for the link:

    Code:
    javascript:showElement('form1POP');
    but when I test it, it doesn't open the window in Firefox or IE. Any suggestions? I placed the button code below so you can see the whole thing.

    Code:
    <a href="javascript:showElement('form1POP');">contact</a>
    The css style of the pop up is set to hidden originally, do I have to remove that using this script? Does the script hide the layer ( ie onload?)

    Thanks

    JF

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    The css style of the pop up is set to hidden originally, do I have to remove that using this script?
    Yes. It shouldn't be hidden originally anyway: non-Javascript users won't be able to see it.
    Does the script hide the layer ( ie onload?)
    No, but it's easy enough to do if you want to:
    Code:
    window.onload = function() {
      showElement("form1POP", false);
    };
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

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