...

View Full Version : problems with FF and Chrome disabling F5



germus
10-02-2012, 07:21 PM
to disable f5 I use this code:

<%
brow=Request.ServerVariables("http_user_agent")
if instr(brow,"MSIE")>0 then tk="MS" else tk="FF" end if
got=tk+"cancelRefresh()"
%>
<html>
<head>
<title>test</title>
<script language="JavaScript">
function MScancelRefresh(){
if (document.all){
if (event.keyCode == 116){
alert('[F5] disabled!');
{
event.keyCode = 0;
event.returnValue = false;
event.cancelBubble = true;
return false;
}
}
}
}
function FFcancelRefresh(who) {
function __keyPress(evt) {
var result = true;
if(evt.which == 116)
alert('[F5] disabled!');
result = false;
return result;
};
if(!who)
who = window;
if(who.document && who.document.captureEvents) {
who.document.captureEvents(Event.KEYDOWN);
who.document.onkeydown = __keyPress;
};
}
</script>
</head>
<body onkeydown="<%=got%>">
...
...
...
</body>
</html>

it run perfectly in IE FF and Chrome

the problem is when I insert in the body a form with input like

<form action="newfolder.asp" >
<input type="text" name="newdir" value="new folder" size="15">
<button type="submit">go</button>

in IE it run perfectly

in FF and Chrome is impossible insert a new folder in input

how is possible?

Logic Ali
10-02-2012, 09:15 PM
if(evt.which == 116)
alert('[F5] disabled!');
result = false;
return result;

You are allowing the return value always to be false, so no keystrokes allowed.

germus
10-03-2012, 10:32 AM
thank you 100 times to perfect analysis :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum