Help Me/Question Delaying Appearance Of Items On Webpage

Status
Not open for further replies.

lapunluyang

Yellow Belt
Any one know of javascript that can delay the appearance of a button or table for x seconds into the page loading?

Ie the page all loads, while the optin box appear 10 seconds after.

I could do it with iframe, ie set an iframe with a redirect in 10 seconds. but there must be a slicker way.

Any help appreciated. thanks
 

AdvanceByDesign

White Belt
Hi lapunluyang,
it's quite straight forward with Javascript:

Give the table/object/div/fieldset/whatever you want to hide an ID (for example, id="my_div") and the following style attribute:

Code:
style="display:none;"
Then have a javascript run on the body onload event with a timeout to display it:

HTML:
<body onload='Javascript:setTimeout("document.getElementById(\"my_div\").style.display=\"block\";", 5000);'>
A complete example:

HTML:
<html>
<body onload='Javascript:setTimeout("document.getElementById(\"my_div\").style.display=\"block\";", 5000);'>

<div style="display:none;" id="my_div">This is a test</div>

</body>
</html>
 
Status
Not open for further replies.
Top