473,738 Members | 7,110 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Gmail: the Back button (vs. Close button)...onBef oreUnload?

Hi,

When in gmail I'm composing a new email message and I bit the browser
back button, I get a dialog that says "Your message has not been sent.
Discard your message?"

But if instead of clicking Back, I hit the Browser Close button, I get
the above message, PLUS if I click "cancel" on that dialog, I get the
following message 'Are you sure you want to navigate away from this
page? Press "Cancel" to remain on this page. Press OK to continue, or
Cancel to stay on the current page.'

This latter dialog is likely the usual onBeforeUnload( ) dialog.

What I don't understand here is why this latter (likely:
unBeforeUnload) dialog doesn't appear in the case where the user
clicks "cancel" on the dialog shown when they have hit the Back
button. Both Back and Close trigger onBeforeUnload.

Any thoughts?

Regards,
Allan

Mar 20 '07 #1
5 9705
On Mar 20, 3:39 pm, allan.yo...@gma il.com wrote:
Hi,

When in gmail I'm composing a new email message and I bit the browser
back button, I get a dialog that says "Your message has not been sent.
Discard your message?"

But if instead of clicking Back, I hit the Browser Close button, I get
the above message, PLUS if I click "cancel" on that dialog, I get the
following message 'Are you sure you want to navigate away from this
page? Press "Cancel" to remain on this page. Press OK to continue, or
Cancel to stay on the current page.'

This latter dialog is likely the usual onBeforeUnload( ) dialog.

What I don't understand here is why this latter (likely:
unBeforeUnload) dialog doesn't appear in the case where the user
clicks "cancel" on the dialog shown when they have hit the Back
button. Both Back and Close trigger onBeforeUnload.

Any thoughts?

Regards,
Allan
The second window you see is the result of returning a value from the
onbeforeunload event handler. If the function you have defined as the
onbeforeunload handler returns ANYTHING (even null) that little window
will pop up.

Try it out.

Mar 22 '07 #2
On Mar 20, 3:39 pm, allan.yo...@gma il.com wrote:
Hi,

When in gmail I'm composing a new email message and I bit the browser
back button, I get a dialog that says "Your message has not been sent.
Discard your message?"

But if instead of clicking Back, I hit the Browser Close button, I get
the above message, PLUS if I click "cancel" on that dialog, I get the
following message 'Are you sure you want to navigate away from this
page? Press "Cancel" to remain on this page. Press OK to continue, or
Cancel to stay on the current page.'

This latter dialog is likely the usual onBeforeUnload( ) dialog.

What I don't understand here is why this latter (likely:
unBeforeUnload) dialog doesn't appear in the case where the user
clicks "cancel" on the dialog shown when they have hit the Back
button. Both Back and Close trigger onBeforeUnload.

Any thoughts?

Regards,
Allan
Here's a good page that describes what's happening:

http://www.hunlock.com/blogs/Masteri...ith_Javascript

Mar 22 '07 #3
Hi Tom,

Thanks for your reply.

What is still not clear to me, even after reading page you suggested,
is the handling of the case in GMail where the user has a dirty
document and hits the browser's Back button.

In this case, GMail shows what appears to be a GMail specific OK|
Cancel modal dialog. If the user hits OK, no followup dialog is shown,
so in this case an empty string is probably returned from their
onbeforeunload handler.

But, if the user hits Cancel, the browser does not navigate away from
the dirty document, and the default onbeforeunload query dialog
doesn't show either. So my question is, in this Cancel case, how is
Gmail prevent the navigation away from the current page without
showing this query dialog? What would need to be returned from their
onbeforeunload handler in order to achieve this?

Regards,
Allan

Mar 22 '07 #4
On Mar 22, 12:25 pm, allan.yo...@gma il.com wrote:
Hi Tom,

Thanks for your reply.

What is still not clear to me, even after reading page you suggested,
is the handling of the case in GMail where the user has a dirty
document and hits the browser's Back button.

In this case, GMail shows what appears to be a GMail specific OK|
Cancel modal dialog. If the user hits OK, no followup dialog is shown,
so in this case an empty string is probably returned from their
onbeforeunload handler.

But, if the user hits Cancel, the browser does not navigate away from
the dirty document, and the default onbeforeunload query dialog
doesn't show either. So my question is, in this Cancel case, how is
Gmail prevent the navigation away from the current page without
showing this query dialog? What would need to be returned from their
onbeforeunload handler in order to achieve this?

Regards,
Allan
I'b be lying if I said this were anything more than a guess, but their
site uses frames. What I think you're seeing is cimbined behaviour
from onbeforeunload handlers for two different pages. My guess would
be that in scenario 1 (backbutton) you're seeing the handler for the
visible frame, and in scenario 2 (close) your seeing both the handler
from the visible frame, plus the one from the non-visible frame.

Mar 22 '07 #5
Hi Tom,

Still, whether two frames are used or not, how can a page or frame
that handles onbeforeunload avoid showing the default browser dialog
and yet support cancelling of the unload? To my knowledge, the only
way to cancel the unload is to return a non-empty string in the
onbeforeunload handler, which causes the browser to show its dialog.
If you pass an empty string, the page will unload.

Regards,
Allan

Mar 22 '07 #6

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

Similar topics

5
2723
by: Reggie | last post by:
Hi and TIA! I have a form and have set the Close Button to false so that users must exit using my close button. However when I open a Report from this form I want the close button to be available from the report print preview window. However, the first time I open the report to preview it the close button (X) in upper right hand corner is there. When I close the preview and open it again it is not there unless I close the app down and...
13
22724
by: lightzizo | last post by:
All, How can I disable or remove the close button in the screen. thanks
2
4188
by: David | last post by:
Is there anyway to get a different DialogResult or detect that the user clicked the close button on a MessageBox? I have a message box that pops up when my program first starts that only has an ok button but if the user clicks the close button the DialogResult is still DialogResult.OK.
2
1639
by: VBLearner | last post by:
How to close the parent and all child forms together at once when click on parent window's close button X?
5
2605
by: lord.zoltar | last post by:
How can I prevent the big close button in the top of the window from closing the window? I want to have and "are you sure?" confirmation so the user must press "Yes" before the program ends. Right now, I've tried catching the FormClosing and FormClosed events. The message box appears at the right time, but since the form is already closing, it doesn't matter if the user presses "Yes" or "No". how do I cancel the FormClosing?
6
3968
by: mikes8arms | last post by:
Version: Flash MX (A.S. 2.0) Hello. I haven't posted since signing on a few weeks ago. I've searched your site seeking an answer or answers to the concept of creating a "close button" for my external swf's. I've also searched engines; Ask.com, Yahoo.com, Lycos.com, etc.. I've tried the following methods of code as solutions, with no success: on press{ unloadMovie (1); } ..or...
2
3362
by: Bruce | last post by:
Hello, I have a form in an Access 2003 application which opens maximized. Its CloseButton property is set to false. On this form I have a command button that opens a report in preview mode. The report opens fine. It opens maximized as one would expect. However, the report preview window's close button is disabled which is confusing to my users (they have to click the resize button on the preview window which then restores the close...
1
11350
by: sreedhardasi | last post by:
Hi, I would like to call a javascript function when user clicks on browser's close button. Here is the scenario. 1. User clicks browser close button. 2. User will be displayed a popup or a div with two buttons (Yes or No) by calling a Javascript function 3. "No" will close the window. 4. "Yes" will cancel the user action and redirect him/her to different
5
5893
by: Tony | last post by:
I am continuing to develop an Access 2007 application which was originally converted from Access 2003. In Access 2003 I was able to disable the Access Close button in the top righthand corner of the screen. I have been unable to find any way to disable this button in Access 2007 and subsequently I have been forced to find ways to detect and handle the situations after the Access Close button has been clicked. I have been largely...
0
8788
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,...
1
9263
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
8210
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6751
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6053
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4570
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...
1
3279
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
2745
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2193
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.