How to get and cancel the reload event (F5, Reload nutton, ...) within a browser

Discussion in 'Javascript' started by Stefan Mueller, Nov 4, 2005.

  1. I've a webpage with a dynamically created table. If the user presses F5,
    clicks on the reload button, ... the webpage reloads and the dynamically
    created table will be resetted. Is there something like an reload event
    which I can test (e.g. with a JavaScript) and ask the user if he/she really
    wants to reload the webpage and which I can cancel if the user says that
    he/she doesn't want to reload the webpage?

    Stefan
     
    Stefan Mueller, Nov 4, 2005
    #1
    1. Advertising

  2. Stefan Mueller

    Randy Webb Guest

    Re: How to get and cancel the reload event (F5, Reload nutton, ...)within a browser

    Stefan Mueller said the following on 11/3/2005 11:09 PM:
    > I've a webpage with a dynamically created table. If the user presses F5,
    > clicks on the reload button, ... the webpage reloads and the dynamically
    > created table will be resetted. Is there something like an reload event
    > which I can test (e.g. with a JavaScript) and ask the user if he/she really
    > wants to reload the webpage and which I can cancel if the user says that
    > he/she doesn't want to reload the webpage?


    You can try onunload and onbeforeunload. But for the most part, you
    can't do what you are trying and make it fail proof. Let your users
    learn the mistake of waiting to redo what they just screwed up and they
    will learn, quicker than you asking them, not to hit the F5 key/Refresh
    Button.

    --
    Randy
    comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
     
    Randy Webb, Nov 4, 2005
    #2
    1. Advertising

  3. With onUnload I'm able to open a confirm box to ask if the user really'd
    like to reload the page. But afterwards I'm not able to prevent the
    reloading of the page if the user says 'No'.
    However Randy, I guess you're right, I have to educate the users not to
    reload the page while filling out the form.

    Stefan
     
    Stefan Mueller, Nov 5, 2005
    #3
  4. Stefan Mueller

    VK Guest

    Stefan Mueller wrote:
    > With onUnload I'm able to open a confirm box to ask if the user really'd
    > like to reload the page. But afterwards I'm not able to prevent the
    > reloading of the page if the user says 'No'.
    > However Randy, I guess you're right, I have to educate the users not to
    > reload the page while filling out the form.


    IMHighlyHO it's kind of reverse thinking because your real task is not
    to alert users that they gonna loose their input, but ensure that they
    will *not* loose their input.
    Both IE and Gesko (Firefox inclusive) have special mechanics for it
    allowing you to have data store on the client side to keep the current
    page snapshot. IE does it through userData behavior, Gesko through
    XPCOM interfaces. For ancient (as well as modern but mentally retarded)
    browsers you still can semi-mimic it through the cookies (if enabled).
    It is not as simple as to disable an interface button but *much* more
    convenient and appreciated by the end users.
     
    VK, Nov 5, 2005
    #4
  5. Yea, it really makes sense what you say. I'll think about your solution.

    Thanks for your reply
    Stefan
     
    Stefan Mueller, Nov 5, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?ZGhucml2ZXJzaWRl?=

    javascript location.reload causes "retry / cancel" popup

    =?Utf-8?B?ZGhucml2ZXJzaWRl?=, Mar 14, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    13,115
    chandruvkumar
    Apr 28, 2008
  2. csgraham74
    Replies:
    5
    Views:
    5,528
    csgraham74
    Jun 14, 2005
  3. K B
    Replies:
    1
    Views:
    9,146
    Christopher Reed
    Mar 29, 2006
  4. dave

    stumped...table - row - click event, cancel checkbox event

    dave, Sep 2, 2006, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    231
  5. Alexander van Meerten
    Replies:
    3
    Views:
    133
    Janwillem Borleffs
    Oct 14, 2003
Loading...

Share This Page