473,626 Members | 3,334 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2133


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.onbefore unload = 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.goo gle.com...
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*****@agrico reunited.com>
comp.lang.javas cript 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
5780
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. How do I do this in VB.NET? Just hiding a form won't do as I need the logic in the OnLoad event to execute when the form loads each time. -- ------------------------------------ Wayne Wengert wayne@wengert.org
0
834
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 using this forms application wizard prevents thewindow from opening. The program otherwise runs correctly. Inoticed that the wizard gave me a main with the notation: int APIENTRY main(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR ...
7
2569
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
6647
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 "OnBeforeUnload" event is the best bet - this does as I wish... Except it doesn't distinguish between hyperlinks within the site and hyperlinks outside it. I.e. simple Hyperlink button will raise the Unload event when clicked,
10
1739
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 projekt. The reason why I am asking is that I am creating a program and I need a Splash-screen (like the tiny screen that appears when programs like Word starts), and when the Splash-screen has been loaded for a couple of seconds it should be...
1
7037
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 question it causes the application to flash and deactivate. I was able to activate it again but it looks sort of stupid to have the application flash when it should simply return the user to the app. Any ideas around this? I know I can do it easliy...
6
3934
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 signal to server. This seems to be achievable with body unload events, but it is little too much, as even if user navigate within my site, this event will be generated, this can be avoided by handling onclick of each link, so that I'll know exactly...
1
1744
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 information, and a method within that class to calculate the weekly pay. Once stop is entered as the employee name the application should terminiate. Below is my previous code and some of what I think I need for this assignment. Any help would be great....
0
8269
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8203
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8711
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8642
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8368
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
4094
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4206
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2630
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1515
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.