PDA

View Full Version : Showing Hidden Elements (RESOLVED)



I_Love_Privacy
Mar 14th, 2008, 07:37 PM
Hi,
I'm new to javascript, so forgive me if this question is too basic.
I'm trying to show an HTML element after a several second delay.
I used the following code to make an element hide:
<script language="javascript">
var timerID;
function ShowLayer(id){ document.getElementById().style.display = "block"; }
function HideTimedLayer(id){ clearTimeout(timerID); document.getElementById(id).style.display = "none"; }
function timedLayer(id){ setTimeout("HideTimedLayer(\"" + id + "\")", 2500); }
</script>
How would I customize this to show an already hidden element?


Thanks in Advance!

Kor
Mar 14th, 2008, 09:08 PM
Like this?


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<script type="text/javascript">
function showDiv(id){
var obj = document.getElementById(id);
obj.style.display='block';
}
</script>
</head>
<body>
<div id="mydiv" style="display:none">MY div</div>
<br>
<span onclick="setTimeout(function(){showDiv('mydiv')},2500)">Show me the div</span>
</body>
</html>

I_Love_Privacy
Mar 15th, 2008, 03:12 AM
Thank you Kor. That did the trick!