- From: Shropshire, Andrew A <shropshire@att.com>
- Date: Fri, 2 Jan 2009 09:36:57 -0500
- To: <public-webapps@w3.org>
- Message-ID: <24D5F2204CBFC84499520C14CC11036C0823ABB7@vna-exch1.gsi.grci.com>
I'd like to propose an onNavigateToNewPage event for the window object. This would be distinguished from the onUnload event in that the event is only fired when the user navigates to a new page whereas onUnload is fired additionally for when the user closes the web page or browser. When the user navigates to a new page (rather than closing the page), onNavigateToNewPage would be fired first, followed by onUnload. In the onNavigateToNewPage event handler, if the event handler returns false, the navigation to the new page is cancelled and the onUnload event is not fired (some visual indication to the user is made by the browser that their navigation has been canceled by the web page with a note that they may close the page). If the onNavigateToNewPage event handler returns true, the navigation to the new page proceeds and onUnload is called. If the user closes the page, onNavigateToNewPage is not fired, but onUnload is. The advantages of this approach are: 1) The web page designer can detect when the browser back button is hit or when the user goes to a link that is not on the page and cancel this navigation. 2) This provides the web page designer the ability to warn the user that navigating away will cause any form information not yet posted back to the server to be lost and allow the user to cancel their request. This can be done without requiring a page refresh. 3) In some situations, the web page designer may wish to block navigation to any link but those specified on the page (for example, in order to recreate a desktop's modal dialog capability) and not show a confirm dialog. 4) Should a web page designer cancel all navigations away from the page just to be malicious, the user can still close the page (since closing the page does not fire the onNavigateToNewPage event). The user is made aware that navigating away from the page is being blocked by the page by the visual indicator mentioned above (which also suggests closing the page as a way around the block). Existing approaches such as onbeforeunload() have the following disadvantages: 1) They always show a confirm dialog (this sometimes is not desirable). 2) The text in the confirm dialog is not fully editable and may not be appropriate in some situations. 3) They do not distinguish between navigating away from the page and closing the page. Andrew Shropshire AT&T Government Solutions, Inc. 703-506-5708 This e-mail and any files transmitted with it are AT&T property, are confidential, and are intended solely for the use of the individual or entity to whom this e-mail is addressed. If you are not one of the named recipient(s) or otherwise have reason to believe that you have received this message in error, please notify the sender and delete this message immediately from your computer. Any other use, retention, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited.
Received on Friday, 2 January 2009 14:37:45 UTC