Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    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?

  • #2
    Senior Coder Logic Ali's Avatar
    Join Date
    Sep 2010
    Location
    London
    Posts
    1,028
    Thanks
    0
    Thanked 207 Times in 202 Posts
    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.

  • Users who have thanked Logic Ali for this post:

    germus (10-03-2012)

  • #3
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    thank you 100 times to perfect analysis


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •