Javascript SetTimeout
NOTE: If you have pop-ups blocked, the code below won't work, but luckily, the setTimeout tutorial works either way.
function yup() {
setTimeout("window.open('http://google.com')", 3000);
}
<body onLoad=yup()>
-We
create a function and name it
yup because we like the name yup.
-We call Javascript's built-in
setTimeout method which takes two arguments.
---Our first argument is what we want to happen. (
Open a window and go to google.)
---Our second argument is how long in milliseconds should the browser wait before executing our first argument. (example: 3000 is 3 seconds.)
-We
call our
yup function in the
HTML body tag with
Javascript onLoad.
NOTE: Since we called Javascript's built-in window.open method, which gets an argument too, we enclosed our entire first argument in double quotes, and then put our google URL in single quotes.
Free Copy and Paste Javascript Code:
<script type="text/javascript">
<!--
function yup() {
setTimeout("window.open('http://google.com')", 3000);
}
-->
</script>
<body onLoad=yup()>
Resources:
Javascript Create a Function
Javascript Call a Function
HTML Tutorials
Javascript Open Window
Javascript onLoad
Click HERE to comment or discuss at iLoveTheCode GOOGLE Group
| | | CSS David McFarland |
| | | |
| | | |