js屏蔽F5和后退
以下代码, 在file的输入框内输入文字,
按下F5或者后退出错, 为什么啊?
请指教
<!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
你用的那个浏览器
------解决方案--------------------
Js代码
<script language="javascript">
//禁止用F5键
function document.onkeydown()
{
if &n