Results 1 to 3 of 3

Thread: New Div Tag Question

  1. #1
    Join Date
    Oct 2006
    Posts
    94
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Cool New Div Tag Question

    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.

    Code:
    <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.

  2. #2
    Join Date
    Oct 2006
    Posts
    94
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Cool

    I figured it out!

    All it was, was some extra css needed.

    For those who might need it:

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

  3. #3
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Yep. Or you could use hide('div4') on the body tag if you like.
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

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
  •