js禁⽌页⾯刷新与后退的⽅法本⽂实例讲述了js禁⽌页⾯刷新与后退的⽅法。分享给⼤家供⼤家参考。具体实现⽅法如下:<script language="javascript">
//禁⽌⽤F5键
keydown()
{
if ( event.keyCode==116)
{
event.keyCode = 0;
event.cancelBubble = true;
return false;
}
}
//禁⽌右键弹出菜单
extmenu()
{
return false;
}
//下⾯代码实现全屏显⽰
load(){
var Request = new Array();//保存参数
js原型和原型链的理解var s = location.search.substring(1);
if (s && s!=""){
var list = s.split("&");
for (var i=0; i < list.length; i++){
var pair = list[i].split("=");
if (pair[0] && pair[0] !=""){
Request[unescape(pair[0])] = unescape(pair[1]);
}
}
}
var fullscreen=Request["fullscreen"];
if(fullscreen!="yes"){
var file =self.location;
var a = window.open("about:blank","","fullscreen=yes");
self.opener=null;
self.close();
a.location=file + "?fullscreen=yes";
}
}
</script>
<script language="Javascript"><!--
//屏蔽⿏标右键、Ctrl+N、Shift+F10、F11、F5刷新、退格键
//Author: meizz(梅花⾬) 2002-6-18
extmenu(){urnValue=false;}
//屏蔽⿏标右键
help(){return false}
//屏蔽F1帮助
keydown()
{
if ((window.event.altKey)&&
((window.event.keyCode==37)|| //屏蔽 Alt+ ⽅向键←
(window.event.keyCode==39))) //屏蔽 Alt+ ⽅向键→
{
alert("不准你使⽤ALT+⽅向键前进或后退⽹页!");
}
/
* 注:这还不是真正地屏蔽 Alt+ ⽅向键,
因为 Alt+ ⽅向键弹出警告框时,按住 Alt 键不放,
⽤⿏标点掉警告框,这种屏蔽⽅法就失效了。以后若
有哪位⾼⼿有真正屏蔽 Alt 键的⽅法,请告知。*/
if ((event.keyCode==8) || //屏蔽退格删除键
(event.keyCode==116)|| //屏蔽 F5 刷新键
(lKey && event.keyCode==82)){ //Ctrl + R
event.keyCode=0;
}
if (event.keyCode==122){event.keyCode=urnValue=false;}
/
/屏蔽F11
if (lKey && event.keyCode==78) urnValue=false;
//屏蔽 Ctrl+n
if (event.shiftKey && event.keyCode==urnValue=false;
//屏蔽 shift+F10
if (window.event.srcElement.tagName == "A" && window.event.shiftKey) urnValue = false;
//屏蔽 shift 加⿏标左键新开⼀⽹页
if ((window.event.altKey)&&(window.event.keyCode==115))
//屏蔽Alt+F4
{
window.showModelessDialog("about:blank","","dialogWidth:1px;dialogheight:1px"); return false;
}
}
</script>
希望本⽂所述对⼤家的javascript程序设计有所帮助。
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论