SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Not Bad, eh? Justin Sampson's Avatar
    Join Date
    Aug 2000
    Location
    N.S., Canada
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    Can someone tell me how I hide a layer when someone clicks a link? I used to know how but I forget.

    Thanks,
    Justin Sampson

  2. #2
    SitePoint Member
    Join Date
    Feb 2001
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    bru i got quite a large script that does not only hide layers but a load of other cool layer funtions i really think you'll enjoy this
    so i'll mail you the whole script rather than post it the example is a bit big.... but you can make it smaller
    for yourself

  3. #3
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    A JavaScript function to hide a layer given its ID is:

    Code:
    function hideLayer(layerid) {
      if (document.getElementById) {
        // DOM-compliant browsers (MSIE5, NSN6, O5)
        document.getElementById(layerid).style.visibility='hidden';
      } else if (document.all) {
        // MSIE4
        return document.all[layerid].style.visibility='hidden';
      } else if (document.layers) {
        // NSN4
        return document.layers[layerid].visibility='hidden';
      } else {
        // Trap DHTML-impaired browsers 
        //alert("Your browser does not support DHTML!");
        return false;
      }
    }
    The to call this when clicking a link (say you wanted to hide the layer with ID "myLayer"):

    Code:
    <a href="javascript:hideLayer('myLayer');">...</a>
    This code will work in NS4.x, NS6, MSIE 4+, and Opera 5.x.
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference


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
  •