CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   JavaScript programming (http://www.codingforums.com/forumdisplay.php?f=2)
-   -   problems with FF and Chrome disabling F5 (http://www.codingforums.com/showthread.php?t=274959)

germus 10-02-2012 06:21 PM

problems with FF and Chrome disabling F5
 
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 08:15 PM

Quote:

Code:

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 09:32 AM

thank you 100 times to perfect analysis :thumbsup:


All times are GMT +1. The time now is 03:17 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.