how to , Disable F5 key

Discussion in 'HTML & Website Design' started by seekndestroy88, Sep 27, 2009.

  1. #1
    I want to disable F5 key , i used a popup to open a page from which i disabled the toolbar for refresh button and address bar but i also want to disable F5 key so that anyone could not refresh the page.
    i searched and found the following
    <script language=javascript>
    document.onkeydown = function(){

    if(window.event && window.event.keyCode == 116)
    { // Capture and remap F5
    window.event.keyCode = 505;
    }

    if(window.event && window.event.keyCode == 505)
    { // New action for F5
    return false;
    // Must return false or the browser will refresh anyway
    }
    }

    </script>

    but its not working ... common experts please help
     
    seekndestroy88, Sep 27, 2009 IP
  2. awesometbn

    awesometbn Peon

    Messages:
    268
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    This is a problem. You cannot depend on the user and know their browser settings ahead of time. What if they disable Javascript? What if they are using a different browser than IE or Firefox, such as Opera or Safari or Konquerer? Take a look at the following blog post.

    Stop and Disable Web Pages Auto Refresh or Reload in Firefox
    hxxp://www.mydigitallife.info/2009/07/27/stop-and-disable-web-pages-auto-refresh-or-reload-in-firefox/

    This will alert the user to any meta refresh or other method used by the web page to refresh. So I think you will have a hard time "controlling" what the user wants to do such as trying to disable their F5 function key. You might have better results thinking more along the terms of using Flash instead of HTML to present your web page. I think if you hit F5 to refresh a page with Flash it actually starts over and reloads the entire file, which is probably not going to help anyone cheat or gain an advantage with a game.

    Do some more research and let us know what you decide to do, and what works. Curious to hear your results. Thanks.
     
    awesometbn, Sep 27, 2009 IP
  3. seekndestroy88

    seekndestroy88 Peon

    Messages:
    127
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Actually now its time to tell you the whole situation so that you might can suggest me some alternate method ..

    I broadcast sports events live , but to prevent copyright laws against my domain i use another domain which opens in a popup .. ( you can view the situation on zemtv.com/sports/soccer and click "watch" )
    now i used hotlink protection for ".html" which can be only opened from zemtv.com(i-e direct access to the second domain will not be allowed) , So i don't want people to refresh that popup , i want if they want to refresh they should come back again to zemtv.com and again should access the page ..

    I think a php script should help me , which could open a session and when user refresh the page the session will start from first step .. am i right ?

    or you can suggest me some other alternative ?
     
    seekndestroy88, Sep 27, 2009 IP