本文实例讲述了js禁止页面刷新与后退的方法。分享给大家供大家参考。具体实现方法如下:
禁止用F5键
function document.onkeydown()
{
if ( event.keyCode==116)
{
event.keyCode = 0;
event.cancelBubble = true;
return false;
}
}
//禁止右键弹出菜单
function document.oncontextmenu()
{
return false;
}
//下面代码实现全屏显示
function window.onload(){
var Request = new Array();//保存参数
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";
}
}
希望本文所述对大家的javascript程序设计有所帮助。