最近有客户反映系统一个页面可以打开过个,因为页面里面有计时功能,会导致计时不准确,网上收集了一些js屏蔽的代码,在这里记录下。
<script type="text/javascript"> function contextMenuCheck() { event.returnValue = false; } function helpCheck() { return false; } //禁止鼠标左键和Ctrl键打开新窗口 function leftclick() { if (window.event.button == 1 && window.event.ctrlKey) {//2为右键 alert("禁止操作!"); } } //屏蔽其他功能键 function checkKey() { var k = window.event.keyCode; //屏蔽 F5 刷新键 if (k == 116) { window.event.keyCode = 0; window.event.returnValue = false; } if (window.event.ctrlKey && k == 82)//Ctrl + R window.event.returnValue= false; if (window.event.ctrlKey && k == 78)//屏蔽Ctrl+n window.event.returnValue = false; if (window.event.ctrlKey && k == 87)//屏蔽Ctrl+w window.event.returnValue = false; if (event.shiftKey && k==121)//屏蔽 shift+F10 window.event.returnValue = false; //屏蔽shift+鼠标左键打开新页面 if (window.event.srcElement.tagName == "A" && window.event.shiftKey) { //禁止事件冒泡 window.event.cancelBubble = true; //设置事件的返回值 window.event.returnValue = false; return false; } } var mouseCur = 0; function mouseMove(ev) { ev= ev || window.event; var mousePos = mouseCoords(ev); document.getElementById("yyy").value = mousePos.y; //鼠标y轴的坐标 mouseCur = mousePos.y; } function mouseCoords(ev) { if(ev.pageX || ev.pageY){ return {x:ev.pageX, y:ev.pageY}; } return { x:ev.clientX + document.body.scrollLeft - document.body.clientLeft, y:ev.clientY + document.body.scrollTop - document.body.clientTop }; } var winWidth = 0; var winHeight = 0; //函数:获取尺寸 function findDimensions() { //获取窗口宽度 if(window.innerWidth) winWidth = window.innerWidth; else if((document.body) && (document.body.clientWidth)) winWidth = document.body.clientWidth; //获取窗口高度 if(window.innerHeight) winHeight = window.innerHeight; else if((document.body) && (document.body.clientHeight)) winHeight = document.body.clientHeight; /*nasty hack to deal with doctype swith in IE*/ //通过深入Document内部对body进行检测,获取窗口大小 if(document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth) { winHeight = document.documentElement.clientHeight; winWidth = document.documentElement.clientWidth; } } window.onblur = function (e) { e = e || window.event; if (window.ActiveXObject && /MSIE/.test(navigator.userAgent)) { //IE //如果 blur 事件是窗口内部的点击所产生,返回 false, 也就是说这是一个假的 blur var x = e.clientX; var y = e.clientY; var w = document.body.clientWidth; var h = document.body.clientHeight; if (x >= 0 && x <= w && y >= 0 && y <= h) { window.focus(); return false; } } //获取鼠标位置 findDimensions(); //如果失去焦点, 并且焦点不在document里面, 在工具栏或者其他窗口 if (!document.hasFocus() && mouseCur < winHeight) { window.focus(); } } //注册键盘按键 document.onkeydown = checkKey; //注册点击事件 document.onclick = checkKey; //注册鼠标左键和Ctrl键打开新窗口事件 document.onmousedown = leftclick; //注册鼠标移动事件 document.onmousemove = mouseMove; //注册屏蔽鼠标右键 document.oncontextmenu = contextMenuCheck; //注册屏蔽F1帮助 window.onhelp = helpCheck; </script> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>考试窗口</title> <meta name="Generator" content="EditPlus"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> </head> <body> <h1> 考试窗口 </h1> <input id="yyy" type="text"> 鼠标y坐标 </body> </html>
相关推荐
1. **在浏览器地址栏输入JavaScript代码**: ```javascript javascript:alert(document.onselectstart = document.oncontextmenu =document.onmousedown = document.onkeydown = function(){return true;}); ``` ...
1.将该实例复制到C:\Inetpub\wwwroot下; 2.选择浏览器的“工具”-“安全”-“本地Intranet”-“自定义级别”-“活动脚本”中选用“禁用”单选框 3.在浏览器中输入下述地址:http://localhost/1.2.htm • ...
1.将该实例复制到C:\Inetpub\wwwroot下; 2.选择浏览器的“工具”-“安全”-“本地Intranet”-“自定义级别”-“活动脚本”中选用“禁用”单选框 3.在浏览器中输入下述地址:http://localhost/1.2.htm • ...
地址栏图标 <link rel="Shortcut Icon" href="favicon.ico"> favicon.ico 名字最好不变16*16的16色,放虚拟目录根目录下 收藏栏图标 查看源码 查看网页源代码 onclick="window.location = "view-source:"+ ...
如果没有安装IDE设备,我们可以选择NONE参数,这样可以加快系统的启动速度,在一些特殊操作中,我们也可以通过这样来屏蔽系统对某些硬盘的自动检查。 图中2部分是DRIVE A和DRIVE B软驱设置,如果没有A或B驱动器,...