View Full Version : Working on just one page only

02-25-2003, 06:02 PM
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:
//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....


02-25-2003, 06:08 PM
Well, first I hope this is in an onload triggered function, otherwise the script will never find the DIV.
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;

02-25-2003, 06:40 PM
Is the "o" the part that ids the <div>???

<div id="o">

02-25-2003, 07:09 PM
No, you send the id to the function when you call it

<body onload="hideElem('z1');">