473,395 Members | 1,675 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,395 software developers and data experts.

Before Unloading I need to prompt the user if the from has changed

Hi,
I need to promt the user when he moves away from the page by
clicking an of the links available on the page.
I was trying to use the onbeforeunload function but it seems it is a
jScript function rather than a javascript function which means it will
not work in Mozilla.

is there anyway that the user can be prompted to stay on the page.
Another big problem is that the i want a different message than the
one shown. This is because the prompt the explorer provides is 'do you
want to navigate away from this page ?' Is there any way i can do this
???

i am working in struts therefore it becomes useless to rewrite the
url.
Please help

Thanx in advance
Jul 23 '05 #1
3 2103


sancha wrote:

I need to promt the user when he moves away from the page by
clicking an of the links available on the page.
I was trying to use the onbeforeunload function but it seems it is a
jScript function rather than a javascript function which means it will
not work in Mozilla.


onbeforeunload was introduced by IE 5 I think but recent Mozilla
versions implement that too, when I have the following

window.onbeforeunload = function (evt) {
var message = 'Are you sure you want to leave?';
if (typeof evt == 'undefined') {
evt = window.event;
}
if (evt) {
evt.returnValue = message;
}
return message;
}

then Firefox 1.0 for instance asks for confirmation when trying to
navigate away from the page. IE 6 too.

As for JScript and JavaScript, event handlers like onbeforeunload are
part of the client-side object model and not part of the language itself:
<http://jibbering.com/faq/#FAQ2_8>

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
"sancha" <ch**************@gmail.com> wrote in message
news:a9**************************@posting.google.c om...
Hi,
I need to promt the user when he moves away from the page by
clicking an of the links available on the page.
I was trying to use the onbeforeunload function but it seems it is a
jScript function rather than a javascript function which means it will
not work in Mozilla.
Actually, onbeforeunload is an event only available in the IE DOM, it
has nothing to do with JavaScript vs JScript (which are simply two
implementations of ECMAScript).

Second, modern versions of Gecko-based browsers do understand
onbeforeunload.

Third, if someone is leaving your page, they probably want to leave your
page. Asking them if they want to leave your page after they have made a
conscious decision to leave your page seems annoying and pointless.

Fourth, using onbeforeunload, how are you determining that the user is,
in fact, navigating off your page, and not to another page on your site.
onbeforeunload has no way of knowing this, so it will make a prompt
appear for every navigation outside and within your site.
is there anyway that the user can be prompted to stay on the page.
Another big problem is that the i want a different message than the
one shown. This is because the prompt the explorer provides is 'do you
want to navigate away from this page ?' Is there any way i can do this
???
If you want to make use of onbeforeunload, you simply return a string
which will be added to the default prompt. As the documentation at <url:
http://msdn.microsoft.com/workshop/a...foreunload.asp
/> states:

" When a string is assigned to the returnValue property of window.event,
a dialog box appears that gives users the option to stay on the current
page and retain the string that was assigned to it. The default
statement that appears in the dialog box, "Are you sure you want to
navigate away from this page? ... Press OK to continue, or Cancel to
stay on the current page.", cannot be removed or altered."
i am working in struts therefore it becomes useless to rewrite the
url.
Please help


<body onbeforeunload="return 'I want to annoy you so I\'m forcing the
display of this prompt.';">

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #3
Hi,
It is just that i need to prompt the user when he moves off the
page to save the page. Since the message
"Are you sure you want to
navigate away from this page? ... Press OK to continue, or Cancel to
stay on the current page.", cannot be removed or altered is there any
other way that i can do this ? the only way i can think is to attach a
function to all the links on my site. This would do it but since i have
a loi of links on the page it might become a bit tedious.
is there any other way that i can get a different prompt ???

Thanx

Jul 23 '05 #4

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

Similar topics

3
by: Wayne Wengert | last post by:
In VB6 I used to use frmForm1.Show to make a form visible to the user and then use Unload frmForm1 to unload it. I have an app in which I need to "load" and "unload" forms based on user actions....
0
by: Laura Zeafla via .NET 247 | last post by:
I used the .NET forms application wizard. From the form youclick a button and it calls a C++ function through its dll. This function is supposed to pop-up a command prompt window. Something about...
7
by: Weaver | last post by:
I need to check the status of some records (detail records in a master detail form) _before_ moving off the current master record. Anyone know what event will catch this?
4
by: markalroberts | last post by:
Hi, I wish to ask warn the user that there are unsaved changes (if there are) and allow them to cancel navigating away/closing the browser. Investigation leads me to believe the...
10
by: peter hansen | last post by:
I tried a couple of weeks ago but I'll try again :D I old VB6-days it was possible to unload a form bu using the Unload(Form) command. I have tried the Close-function but it'll unload the entire...
1
by: Chris Cairns | last post by:
I have a MDI Application and would like to prompt the user before exit. I placed the following in the FormClosing event. It appears to work properly, however when a user answers no to the...
6
by: hemant.singh | last post by:
Hi all, I am trying to get a way by which I'll know exactly when user goes out of my site by clicking on close button in browser, So that w/e user click close button in browser, I can send a...
1
by: tikney5 | last post by:
I need to modify my current program so that is uses a class to store and retrieve the employees name, hourly rate, and number of hourse worked. Use a constructor to initialize the employee...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.