标签:style blog class code java ext
1 window事件 2 window.onload=function(){alert("页面创建中****");}; 3 window.onunload=function(){alert("页面卸载中****");}; 4 window.onbeforedeactivate =function(){alert("页面卸载中****")};
定时
1 window.status="xxxxx" 2 var now =new Date().toLocaleString(); 3 window.status=now; 4 5 function showTime() 6 { 7 var now=new Date().toLocaleString(); 8 window.status=now; 9 //window.document.write(window.status+"<br/>"); 10 window.document.getElementById("time").innerText=window.status; 11 12 } 13 //window.setInterval("showTime()",1000); 14 15 //window.location.href="http://127.0.0.1:8080/bbs"; 16 17 var size=window.history.length; //浏览器的历史栏,它存放的是该浏览器窗口已访问过的网页内容 18 window.document.write(size); 19 20 //打开新的窗口 21 var newWindow=window.open("function.html"); 22 23 newWindow.close();
触发事件,表单提交是否
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="注册" /> 4 </form> 5 6 <form action="#" method="post" onsubmit="return checkLogin()"> 7 <input type="text" name="username" /> 8 <input type="submit" value="登录" /> 9 </form> 10 11 <script type="text/javascript"> 12 function checkRegister() 13 { 14 var name=window.document.register.username.value; 15 alert(name); 16 return false; 17 } 18 function checkLogin() 19 { 20 var name=window.document.forms[1].username.value; 21 alert(name); 22 return false; 23 } 24 </script>
打开新窗口
1 <script type="text/javascript"> 2 3 4 //打开新的窗口 5 var newWindow=window.open("function.html"); 6 7 newWindow.close(); 8 </script>
标签:style blog class code java ext
原文地址:http://www.cnblogs.com/friends-wf/p/3716071.html