(Javascript) Timed pop up - Printable Version +- howtothings.co.uk (https://www.howtothings.co.uk) +-- Forum: Computing (https://www.howtothings.co.uk/forumdisplay.php?fid=4) +--- Forum: Website Development, Implementation and General Webmaster Support (https://www.howtothings.co.uk/forumdisplay.php?fid=9) +--- Thread: (Javascript) Timed pop up (/showthread.php?tid=138) |
(Javascript) Timed pop up - Mark - 16-06-2010 I've just implemented a timed pop up on the forum that only guests can see, as soon as they load the page it auto starts counting down, then pops up in a javascript pop up. What you need to do: If you're doing this on a webpage, open up your index.html page and put this in the header. (If you already have the HTML and header tags in on your page, you only need them once.) Code: <html> Then in the body of your page, you need: Code: <body> Explanation Code: <script type="text/javascript"> Tells the browser that you're going to be using javascript code. Code: function timedMsg() This is the function that you're setting, the "timedMsg" can be anything you want, it's just the name of the function that you're going to recall later. Code: { This is what the function is going to do, it's task. Then in the body Code: <body onLoad="setTimeout('timedMsg()', 1)"> onLoad means that the Javascript is going to load as soon as you load the webpage, you can then set a timeout; i set mine to 1 millisecond. You also need to recall the function that you set above. If you want to see how this works, head over to: http://mcompute.co.uk as a guest and wait 30 seconds. Hope this has helped, if you have any questions please post or PM me. RE: (Javascript) Timed pop up - Jamez247 - 16-06-2010 Nice tut again Mark xD |