1 Window Event 2 window.onload=function() {Alert ("page creation");}; 3 window.onunload=function() {Alert ("page unloading");}; 4 Window.onbeforedeactivate =function() {Alert ("page unloaded")};
Timing
1window.status= "xxxxx"2 varnow =NewDate (). tolocalestring ();3window.status=Now ;4 5 functionshowTime ()6 {7 varnow=NewDate (). tolocalestring ();8window.status=Now ;9 //window.document.write (window.status+ "<br/>");TenWindow.document.getElementById ("Time"). innertext=Window.status; One A } - //Window.setinterval ("ShowTime ()", +); - the //window.location.href= "Http://127.0.0.1:8080/bbs"; - - varSize=window.history.length;//The browser's History bar, which stores the content of the Web page that the browser window has visited - window.document.write (size); + - //Open a new window + varNewwindow=window.open ("function.html"); A atNewwindow.close ();
Trigger event, whether the form submission
1<form name= "register" action= "Http://127.0.0.1:8080/bbs" method= "POST" onsubmit= "return Checkregister ()" >2<input type= "text" name= "username"/>3<input type= "Submit" value= "register"/>4</form>5 6<form action= "#" method= "POST" onsubmit= "return Checklogin ()" >7<input type= "text" name= "username"/>8<input type= "Submit" value= "Login"/>9</form>Ten One<script type= "Text/javascript" > A functionCheckregister () - { - varName=Window.document.register.username.value; the alert (name); - return false; - } - functionChecklogin () + { - varName=window.document.forms[1].username.value; + alert (name); A return false; at } -</script>
Open a new window
1 <script type= "Text/javascript" >23 4 // Open new window 5 var newwindow=window.open ("function.html"); 6 7 newwindow.close (); 8 </script>