473,396 Members | 2,089 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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
Nov 4 '05 #1
4 2605
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/
Nov 4 '05 #2
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
Nov 5 '05 #3
VK

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.

Nov 5 '05 #4
Yea, it really makes sense what you say. I'll think about your solution.

Thanks for your reply
Stefan
Nov 5 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Darren | last post by:
I have a page that opens a popup window and within the window, some databse info is submitted and the window closes. It then refreshes the original window using window.opener.location.reload(). ...
8
by: DKM | last post by:
Here are the source code files to a Java applet that utilizes LiveConnect to communicate with Javascript, and the HTML file. The thing works both in IE 6.0 and FireFox 1.4. but with some...
0
by: PeacError | last post by:
Using Microsoft Visual Studio .NET 2003, Visual C# .NET 1.1: I apologize if this question has been addressed elsewhere, but I could not find a reference to it in the search engine for this...
8
by: T. Wintershoven | last post by:
Hi all, Is there a simple way in php to reload a page coded within an if statement.(see code below) It's very important that the session stays intact. The filename is RCStudent.php ...
7
by: Schmidty | last post by:
Okay...I have another 'newbie' question; I have a function that loads a page and the action is $_SERVER; In the form that is in a function(method?) within a class a variable is passed back to...
1
by: Christian Sengstock | last post by:
Hi all, i have a js application with several event handlers which i manage via prototype .bindAsEventListener. On normal page navigation ( link navigation ) i finish all events handlers...
7
by: John Gault | last post by:
I experimented with a snippet of JavaScript that will display a "Please Wait" message and graphic while the results of a cgi script is running (the script grabs a bunch of data and formats it in a...
14
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi I tried a google search but could not find anything. I am trying to cause one webpage to reload when a second web page is closed. The second webpage loads data into a session variable and when...
3
by: jojee | last post by:
hi all i need help about how to generate ok/cancel button in C# asp.net by using server controls not html coz my whole project is based on server controls one thing imp is that when user click on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.