PDA

View Full Version : New Div Tag Question



smithster
10-18-2006, 09:09 AM
So my last post was a great success. Plenty of help given, much appreciated. Can hide tags and I can swap them about.

But! A new question I can't believe I didn't think of!! Website is opened for first time, and oh my god!! I got every single div showing up!!

So, how do I get a div to be hidden on first entry? So it only shows up when it is called upon.

This is the script I am using for my divs at the moment.




<html>
<head>
<script language="JavaScript" type="text/javascript">

function hide(obj){
document.getElementById(obj).style.visibility="hidden";
}
function show(obj){
document.getElementById(obj).style.visibility="visible";
}
</script>
</head>

<body>
<a href="#" onclick="hide('div(id)');return false;">hide div(id)</a>
<a href="#" onclick="show('div(id)');return false;">show div(id)</a>
<span onclick="hide('div2');show('div3');return false;" style="text-decoration:underline;cursor:pointer"> Switch content</span>
</body>
</html>


I am thinking it would need some body onload javascript???

Hope someone can help me!!

Thanks in advance.:cool:

smithster
10-18-2006, 09:22 AM
I figured it out!

All it was, was some extra css needed.

For those who might need it:




#div4{
position:absolute;
visibility:hidden;
background:#ffffff;
font-weight:bold;
color:white;
width:100%;
height:100%;
top:0px;
left:0px;
}

tech_support
10-18-2006, 09:32 AM
Yep. Or you could use hide('div4') on the body tag if you like.