日期:2014-05-16  浏览次数:20398 次

js屏蔽F5和后退
以下代码, 在file的输入框内输入文字, 
按下F5或者后退出错, 为什么啊?
请指教
HTML code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE> New Document </TITLE>
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
  <SCRIPT LANGUAGE="JavaScript">
  <!--
    function keyEvent()
    {
        if ((event.keyCode == 116) || (event.keyCode == 8))
        {
            event.keyCode = 32;
            event.cancelBubble = false;
            event.returnValue = false;
            return false;
        }
    }
  //-->
  </SCRIPT>
 </HEAD>

 <BODY onkeydown="keyEvent()">
  <INPUT TYPE="file" VALUE="click">
 </BODY>
</HTML>



------解决方案--------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<SCRIPT LANGUAGE="JavaScript">
<!--
function keyEvent(event)
{
event = event || window.event;
if ((event.keyCode == 116) || (event.keyCode == 8))
{
event.keyCode = 32;
event.cancelBubble = false;
event.returnValue = false;
return false;
}
}
//-->
</SCRIPT>
 </HEAD>

 <BODY onkeydown="keyEvent(event)">
<INPUT TYPE="file" VALUE="click">
 </BODY>
</HTML>
------解决方案--------------------
event.keyCode 
IE,火狐下边定义不一样的,火狐下好像不叫keyCode
你用的那个浏览器
------解决方案--------------------
JScript code

Js代码
<script     language="javascript">          
//禁止用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",&