locked
How to disable Refresh button on Browser. RRS feed

  • Question

  • User-1439385708 posted

     

     

             whenever I will run my application then the refresh button will be enabled whenever I will click on that using mouse it will refresh but I don't want to refresh.

     
    I will be avoid (solve) the refresh on F5 button click.  But I need to disable refresh button on mouse click .

     

    Thursday, June 12, 2008 1:50 AM

Answers

  • User1070236303 posted

    Make a aspx page and write a function which inserts a record in database. on click of button call this event. Once the record gets inserted - Press F5 button from browser and see what happens. You will see same button event gets triggered and inserts one more record.

    So lets say now you are submitting a payment transaction to gateway and suddenly net got slow, then you again refreshed the page. This may lead to submission in gateway twice. : - ( bad practice.

    This is a very old problem, and most of the users know it. So 99% of the users very carefull to click twice on the same button (if there is no any feedback that something happend).

    Also if the users press F5 after a postback most modern browser warn the users that the form already posted back (this true only for regular postbacks)!

    Anyway double postback sometime happens, but the solution for this is not disabling the reload button, instead we need some server side logic to prevent this.

     

    Also you dont want user to copy text or images from site - Though possible :- ) 
     

    Just wondering whether there is any 100% solution for preventing text or image copy from a regular html page?

    (Maybe rendering the page's text from thousands of absolutely positioned 1x1 pix divs is a good starting point... [:D])

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 12, 2008 11:02 AM
  • User-1399914977 posted

    To be honest i never looked for any solution. What i generally do is redirect user to some other page post completion of event. So new page gets loaded. (if its a payment processing page then always redirect - dont take chance).

    But i believe you can acheieve it from firing twice by using following -

    1. Captcha - like a box which says to type  characters by seeing image. This is generally seen in registration page. This prevents auto form submission.

    2. Auto event wireup attribute in aspx page (top line). - You can study more on it.

     

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, June 13, 2008 4:11 AM

All replies

  • User-989915499 posted

    Hi There,

    As far as i know, you cannot disable the refresh button of the web browser.

    However, you have optioon to hide the toolbars of the web browser.

    For more info: http://msdn.microsoft.com/en-us/library/ms536651(VS.85).aspx

    Hope it helps!

    Thursday, June 12, 2008 2:42 AM
  • User-1399914977 posted

    Just copy paste the below inside html head tag 

    <script>
    
    document.attachEvent("onkeydown", my_onkeydown_handler); 
    
    function my_onkeydown_handler() 
    
    { 
    
    switch (event.keyCode) 
    
    { 
    
     
    
    case 116 : // 'F5' 
    
    event.returnValue = false; 
    
    event.keyCode = 0; 
    
    window.status = "You can't refresh this page............."; 
    
    break; 
    
    } 
    
    }
    
    
    
    </script> 
    
    
     
    Thursday, June 12, 2008 2:49 AM
  • User-1439385708 posted

    Hi,

             this is work only for F5 button.

      I need to both on F5 button click and on mouse click on the Reload or Refresh logo on browser click the page could not be refresh.

     Thanks for your help.

     thanks & regards

           priya.
     

            
     

     

     

    Thursday, June 12, 2008 3:03 AM
  • User1070236303 posted

    I think if you try to do this your page will be considered harmfull, and most of your first time visitors leave your page forever.

    You cannot disable (ever) the refresh button, if you can do this it would be a huge security risk.

    But you can use for example the window.onunload event do something, this event will be triggered whenever the user try to leave the current page (by navaigating away, by refreshing, by closing it etc.) 

    Thursday, June 12, 2008 3:33 AM
  • User-1399914977 posted
     
    Disabling right click with JavaScript
    
    <html>
    <head>
    <script language ="javascript">
    function Disable() {
    if (event.button == 2) 
    {
    alert("This action is not possible")
    }
    }
    document.onmousedown=Disable;
    </script>
    </head>
    <body>
    </body>
    </html>
    
     Disabling right click with JavaScript <script language=javascript> function Disable() { if (event.button == 2) { alert("This action is not possible") } } document.onmousedown=Disable; </script>
    Thursday, June 12, 2008 4:45 AM
  • User-1439385708 posted

    Thanks worldClassCoders

     

                 It will also helpful for me.

     

      thanks

       priya.
     

    Thursday, June 12, 2008 5:08 AM
  • User-1439385708 posted

    Thanks d4dennis@inspir3

     

             It will also helpful for me.

     

      thanks

      Priya.
     

    Thursday, June 12, 2008 5:10 AM
  • User1070236303 posted

    Disabling right click with JavaScript
     

    What is the point? The user just need to disable javascript for the page and get the right click, F5, etc. back  [;)]

    Thursday, June 12, 2008 6:43 AM
  • User-1399914977 posted

    Good question try this

    Make a aspx page and write a function which inserts a record in database. on click of button call this event. Once the record gets inserted - Press F5 button from browser and see what happens. You will see same button event gets triggered and inserts one more record.

    So lets say now you are submitting a payment transaction to gateway and suddenly net got slow, then you again refreshed the page. This may lead to submission in gateway twice. : - ( bad practice.

    Or

    Also you dont want user to copy text or images from site - Though possible :- ) 

     

     

    Thursday, June 12, 2008 8:38 AM
  • User-1399914977 posted

    Dont forget to mark the answer - if its helpful and also let others know the correct one : -)

    Thursday, June 12, 2008 8:42 AM
  • User1070236303 posted

    Make a aspx page and write a function which inserts a record in database. on click of button call this event. Once the record gets inserted - Press F5 button from browser and see what happens. You will see same button event gets triggered and inserts one more record.

    So lets say now you are submitting a payment transaction to gateway and suddenly net got slow, then you again refreshed the page. This may lead to submission in gateway twice. : - ( bad practice.

    This is a very old problem, and most of the users know it. So 99% of the users very carefull to click twice on the same button (if there is no any feedback that something happend).

    Also if the users press F5 after a postback most modern browser warn the users that the form already posted back (this true only for regular postbacks)!

    Anyway double postback sometime happens, but the solution for this is not disabling the reload button, instead we need some server side logic to prevent this.

     

    Also you dont want user to copy text or images from site - Though possible :- ) 
     

    Just wondering whether there is any 100% solution for preventing text or image copy from a regular html page?

    (Maybe rendering the page's text from thousands of absolutely positioned 1x1 pix divs is a good starting point... [:D])

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 12, 2008 11:02 AM
  • User1070236303 posted

    Just tested some commercial html text encryptor solution (just choose what get the most hit by google), using firefox + web developer + firebug.

    It looks promising to the regular user at first (no right click, no text selection, select all and copy to notepad from the edit menu show encrypted text, saved page useless etc.)

    But disabling all javascript by web developer turn off all protection, using firebug very easy to see and save the whole page as original. [666]

    So trying to "encrypt"/"protect" the text is pointless (just wondering who pay for this?)

    Also pointless "protecting" images.

    Maybe obfuscating javascript files worth the effort (I don't know how effective against code stealing this technique.)

    Thursday, June 12, 2008 11:40 AM
  • User-1439385708 posted

     Hi WorldClassCoders,

     

             Hey, I tried this what is the reason behind this.

    Why the button call twice time events. Is it possible to avoid twice time calling event, if yes how?

     

    thanks & regards

         Priya.
     

    Friday, June 13, 2008 12:53 AM
  • User1070236303 posted

     

    Hey, I tried this what is the reason behind this.

     Google for [postdata resend], to understand what is this.

    Is it possible to avoid twice time calling event, if yes how?
     

    This is not possible. But it is possible to add some logic in the event:

    - detect that the record is already in the database?

    - save a flag in the viewstate which set for only the first save and subsequent save can be discarded?, etc. 

    Unfortunately the ajax stuff multiply the problem because the refresh, back and forward buttons simply broken down with ajax. This is a big problem (ajax caching problem).

    Friday, June 13, 2008 3:27 AM
  • User-1399914977 posted

    To be honest i never looked for any solution. What i generally do is redirect user to some other page post completion of event. So new page gets loaded. (if its a payment processing page then always redirect - dont take chance).

    But i believe you can acheieve it from firing twice by using following -

    1. Captcha - like a box which says to type  characters by seeing image. This is generally seen in registration page. This prevents auto form submission.

    2. Auto event wireup attribute in aspx page (top line). - You can study more on it.

     

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, June 13, 2008 4:11 AM
  • User1070236303 posted

    2. Auto event wireup attribute in aspx page (top line). - You can study more on it.
     

    What do you want to do with this attribute (how it prevents double post)? Thanks.

    Friday, June 13, 2008 8:19 AM