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
What you're describing is called a 'time out', and can be implemented using the setTimeout(function, timeout) function. I usually recommend jQuery, but in plain JavaScript it would be: Just replace ELEMENT with the DOM ID of whatever button you're looking to display after the page loads.
You could always make the button using flash and then make it fade in after 10 seconds and when clicked go to a url. Very easily done if you know how to use macromedia flash
The javascript code suggested by JeffHood should do it. You need to set the style to display: none in addition to that, of course!
thanks i think this will work. Only think is this is an aweber form sitting in a table. do i need to put the table in div tags labelled? then call it as above?
haha can I ask why? Is it not considered good form to create things with flash anymore? Its just a button, don't think it really matters whether it is flash or created using JavaScript. Nearly everyone has some sort of flash player on their computer...
<script type="text/javascript"> setTimeout(function(){document.getElementById("box").display="block";}, 10000); </script> <div class="box"> <table>x</table> </div> Code (markup): thats just displaying it as it was before, ie at once. what do i need to change
Change to <div id="box" style="display: none"> <table>x</table> </div> You need not use a div, you can add the id/style code for the table and that too will work.
thanks, how do i make it appear, when i change <div id="box" style="display: none"> to <div id="box" style="display: block"> it shows up. how to i call the function.
Try: Try this: <script type="text/javascript"> function showBox(){document.getElementById("box").style.display = 'block';} setTimeout(showBox(), 10000); </script> <div id="box" style="display: none"> x </div> Code (markup):
<body onload='setTimeout("showBox()", 10000);'> ... </body> The first setTimeout argument should be in quotes
ok now theres no error, but it still does not "appear". Its hiddon on load up. and stays that way ;( im thinking dhtml maybe an answer, ie use some behaviour on the layer div. like fade, any advice grateful, thanks. code thats there now:
function showBox(){document.getElementById("box").style.display = 'block';} setTimeout("showBox();", 10000); see if that works
yes! thanks for your help. (rep added to all who helped, even TimonthyJohn. thats great. its a really usefull peice of code that should be available to others: will make the x appear(infatct anything inside the div) after 10 seconds (10000 miliseconds)
Hi tsoprano, trying to PM you - says you inbox is full... pls PM me once you have it sorted for some graphic work cheers