Detecting form navigation

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.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Aug 23rd, 2007, 09:56
New Member
Join Date: Aug 2007
Location: Australia
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
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
Reply With Quote

  #2 (permalink)  
Old Aug 23rd, 2007, 10:23
alexgeek's Avatar
Technical Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,772
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
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)
Reply With Quote
  #3 (permalink)  
Old Aug 24th, 2007, 04:14
New Member
Join Date: Aug 2007
Location: Australia
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
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
Reply With Quote
  #4 (permalink)  
Old Aug 24th, 2007, 15:48
alexgeek's Avatar
Technical Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,772
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: Detecting form navigation

Let me have a google about on this now
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
  #5 (permalink)  
Old Aug 24th, 2007, 16:26
alexgeek's Avatar
Technical Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,772
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
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)
Reply With Quote
Reply

Tags
form, navigation

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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


All times are GMT. The time now is 05:47.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43