Thread: dhtml layers

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    456
    Rep Power
    14
    I need a simple little snippet of DHTML and Javascript code. I've got an HTML table in <div> tags. I want to call a javascript function from the onclick event handler of a link that will set the visibility to false.

    Can someone tell me how to do this?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2001
    Location
    UK
    Posts
    527
    Rep Power
    14
    function hideit(){
    if (document.layers){
    document.layers["mydivid"].visibility='hide';
    }
    else
    {
    document.all["mydivid"].style.visibility='hidden';
    }
    }

    <div ID="mydivid">
    <TABLE>
    etc.
    </TABLE>
    </div>

    <A HREF="#" onClick="hideit();">Mylink</A>

    I think this works.
  4. #3
  5. No Profile Picture
    Senior Citizen
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2001
    Location
    leftcoast
    Posts
    2,019
    Rep Power
    16
    Almost. You left this out:

    <div ID="mydivid" style="position:relative;">

    Without the position: attribute, Nav4 won't create a Layer object, the only element you can set visibility on.

    Alternatively, use position:absolute. This may be in a style id, class, or inline as shown.

    Absolute positioning uses the next outermost positioned element (Layer in Nav4) for its 0,0 point (it may be the document itself); relative positioning offsets the Layer from its normal position in the flow of the document. Nested elements position relative to the positions of their parent element.

    Confused?
    http://www.webreference.com/html/tutorial18/

IMN logo majestic logo threadwatch logo seochat tools logo