PDA

View Full Version : On bodyload settimeout for hiding floating overlay



lsyliu
02-22-2010, 04:01 PM
Hi there,

I hope someone can help me. I want to have insert a JS settimeout to automatically load/action the onclick close button function (in red) after 7 seconds of the page loading. Ive coded the action into a button but im not sure how to translate it into a timed event as well.



<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
<title>Floating Window</title>
<script src="Drag.js"></script>
</head>
<body>

<div id="window" style="position:absolute; z-index:10; left:0px; top:0px; width:100%; height:100%;

background-color:#CCCCCC;">

<div align="center"><img src="images/logo.jpg" width="455" height="54"> </div>

<div style="position:absolute; top:3px; left:95%; float:right;" onClick="this.parentNode.parentNode.style.display = 'none';">

<img src="images/close_button.gif" width="48" height="14" border="0"></a></div>
<div align="center"><img src="images/interstitial.jpg" width=700 height=373

alt=""></div>

</div>

</body>
</html>

thanks!

Lisa

vwphillips
02-22-2010, 05:18 PM
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
<title>Floating Window</title>
<script src="Drag.js"></script>
</head>
<body onload="setTimeout(function(){ document.getElementById('window').style.visibility='hidden'; },7000);">

<div id="window" style="position:absolute; z-index:10; left:0px; top:0px; width:100%; height:100%;

background-color:#CCCCCC;">

<div align="center"><img src="images/logo.jpg" width="455" height="54"> </div>

<div style="position:absolute; top:3px; left:95%; float:right;" onClick="this.parentNode.parentNode.style.display = 'none';">

<img src="images/close_button.gif" width="48" height="14" border="0"></a></div>
<div align="center"><img src="images/interstitial.jpg" width=700 height=373

alt=""></div>

</div>

</body>
</html>

lsyliu
02-23-2010, 09:53 AM
Oh cool thanks will try that! i had something like this:

<script type="text/javascript">
function nodeHide() {
this.parentNode.parentNode.style.display = 'none';
}

document.onload = setTimeout("nodeHide()", 7000);
</script>

but it wasnt working :(

lsyliu
02-23-2010, 01:07 PM
Thanks for the suggestion but i was getting an error from the start and it wasn't timing out. I changed it to this below and now it is timing out but now im getting an error instead of the window closing...

<script type="text/javascript">
<!--
function nodeHide(){
this.parentNode.parentNode.style.display = "none"
}

//-->
</script>
</head>
<body OnLoad = "setTimeout('nodeHide()', 7000)">

It says this.parentNode.parentNode. is null or not an object?

lsyliu
02-23-2010, 01:10 PM
ahh i fixed it to this and it works!

thanks :)

<body onload="setTimeout(function(){ document.getElementById('window').style.display='none'; },7000);">

lsyliu
02-24-2010, 04:47 PM
More issues... apparently this only works in FF?

<body onload="setTimeout(function(){ document.getElementById('window').style.display='none'; },7000);">

i cant get it to work in IE :(