//窗口关闭时执行的函数 window.onbeforeunload = function(){}
//页面加载情况判断document.readyState值可以是complete和interactive function document.onreadystatechange() { if(document.readyState=="complete") alert(document.readyState); }
//屏蔽右键功能和严禁选中操作 //document.οncοntextmenu=new Function("event.returnValue=false;"); //document.onselectstart=new Function("event.returnValue=false;");
//鼠标位置判断 window.event.y和window.event.x window.event.screenY和window.event.screenX window.event.clientY和window.event.clientX window.event.offsetY和window.event.offsetX //x,y是鼠标相对于当前浏览器的位置 //screenX,screenY是相对于用户显示器的位置 //clientX, clientY是鼠标当前相对于网页的位置,当鼠标位于页面左上角时clientX=0, clientY=0;为负数是表示不在网页内; //offsetX, offsetY是鼠标当前相对于网页中的某一区域的位置,当鼠标位于页面中这一区域的左上角时offsetX=0, offsetY=0; //窗口大小判断 document.documentElement.scrollWidth和document.documentElement.scrollHeight //获取窗口的宽和高 //返回值 window.event.returnValue="真的要关闭吗"; //弹出一个确认信息,确认事件是否要执行 return confirm("真的要关闭吗"); //两个是一样的功能
//获取随机数 parseInt(Math.random()*100) //获取1至100之间的随机数