Programming exercises
Make a Jump Tip page:
Requirements:
1. If you open the page, if you do not do anything, then 5 seconds after the automatic jump to a new address, such as MU Class Web home page.
2. If you click the "Back" button, the previous page will be returned.
The code is as follows:
Note that 23 lines to use Window.location.href to specify the window.open words is opened in a new page
27 Line with timer setinterval to call the function can also be used settimeout but at this time, inside and outside the function to add that is commented out 25 lines
10 line hyperlink point must be javascript: Jump function
1<! DOCTYPE html>234<title> Browser Objects </title>5<meta http-equiv= "Content-type" content= "text/html; Charset=gkb "/>67<body>8<!--write a page layout first--9Ten<p><span id= "Second" >5</span> seconds back home <a href= "Javascript:goback ()" > Back </a></p> One A - -<script type= "Text/javascript" > the - //Gets the element that displays the number of seconds, using the timer to change the number of seconds. - varNum=document.getelementbyid ("Second"). InnerHTML; - functionGoto () { +num--; -document.getElementById ("Second"). innerhtml=num; + if(num==0) A { atWindow.location.href= "http://www.baidu.com";//Window.Open's words are opened in a new window and need to be specified with location! - } - //setTimeout ("Goto ()", +); - } -SetInterval ("Goto ()", 1000); - in functionGoBack () { - Window.history.back (); to } + - //control the page jumps through the window's location and history object. the *</script> $</body>Panax Notoginseng"JS Learning" MU class network 8-17 programming Exercise Web page return and jump