This is a discussion on "Detecting form navigation" within the JavaScript Forum section. This forum, and the thread "Detecting form navigation are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Detecting form navigation
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
Detecting form navigation
Hi Everyone,
I'm trying to implement navigation checking on my form. My web site has some buttons/links on the top and provides some input fields below. Once the user starts entering any data I want the navigation, to other links, to be detected/checked. Meaning if a user enters values in any of the text input fields and then clicks on a link on the top, I want to show a message like 'You are now navigating away from the input. Any data entered will not be saved. Please confirm Y/N ?' How do you go about implementing something like this ? Any points on this will be really helpful Thanx in advance Amit |
|
|
|
||||
|
Re: Detecting form navigation
Put a function for unload:
<body onunload="leavingPage()"> then the function: <script type="text/javascript"> /* put what you want to happen when the user leaves */ alert(you are leaving) </script> should work
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
|||
|
Re: Detecting form navigation
Thanx for the reply AlexGeek. Your script does work but not what I'm looking for. Below is my test script :
<html> <head> <title>Test me</title> </head> <body onunload="leavingPage()"> <a href="http://www.hotmail.com">Hotmail</a> <script language="JavaScript"> <!-- function leavingPage() { if (!confirm('Sure Y/N ?')) return false; } //--> </script> </body> </html> What I am expecting is that if I clicked 'Cancel' then I should be returned back to my page and not redirected to the new URL. Also if i refreshed my page again I get this message. I can understand why but that not what I want to do. Thanx Amit PS : The positioning of the script at the end or at the begining inside the <head> tag doesn't work |
|
||||
|
Re: Detecting form navigation
Let me have a google about on this now
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
||||
|
Re: Detecting form navigation
apparently it's impossible (though a lot of people have done it like gmail)...
though there are confusing work arounds. like storing the users input in a cookie, then with the onunload event making then go back in history. unless anyone else knows how to here?
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
![]() |
| Tags |
| form, navigation |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| wrapper not detecting content | saltedm8 | Web Page Design | 4 | Apr 6th, 2008 22:31 |
| Detecting characters between < and > ? | Kerosene | JavaScript Forum | 5 | Jan 16th, 2008 16:32 |
| Detecting server errors in iframes | mungface | JavaScript Forum | 1 | Dec 14th, 2007 01:43 |
| Detecting JRE version using javascript | Nagendra | JavaScript Forum | 0 | Sep 18th, 2006 05:08 |
| Detecting Flash | skuff | Flash & Multimedia Forum | 2 | Aug 19th, 2003 08:38 |