Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Posts
    362
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Working on just one page only

    Please advise how I can get this to work on just one page (called "mypage.html"). I have it in my javascipt file for hiding something but only want it to work on one page or whereever I am using the <div>.

    //in javascript file:
    if(document.getElementById)
    //I tried: if(document.getElementById && document.z1) ...but it didnt work
    {
    document.getElementById("z1").style.visibility = "show";
    }

    //in my html page called "mypage.html":
    <div id="z1">
    html data....

    </div>

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, first I hope this is in an onload triggered function, otherwise the script will never find the DIV.
    Code:
    function hideElem( oId )
    {
        if ( Boolean( var o = document.getElementById( oId ) ) )
        {
            o.style.visibility = "visible";
        }
    }
    . 'show' is the NS4 value for the visibility property. Seeing as how NS4 doesn't supoprt getElementById, I'm assuming you want to move foward, so 'visible' is the proper value;
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Posts
    362
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Is the "o" the part that ids the <div>???

    <div id="o">

  • #4
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No, you send the id to the function when you call it

    <body onload="hideElem('z1');">
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”


  •  

    Posting Permissions

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