Re: [hwg-language] Re: Stopping a user from navigating away from a document

by "Rajnish Bhaskar" <r.bhaskar(at)educ.gla.ac.uk>

 Date:  Wed, 21 Jan 2004 16:14:27 -0000
 To:  "Ches" <ches(at)io.com>,
ches(at)io.com
 Cc:  hwg-languages(at)hwg.org
 References:  localhost
  todo: View Thread, Original
> What session cookies are you using? D0 you have the pragma no cache
> code in your meta tags? Meta Refresh tags?

Er, I'm using Java servlet sessions which handles that automatically. 
 I'm not manually setting any headers or meta tags.  Sorry, I don't 
see how this is relevent to the question?

Raj.

> Rajnish Bhaskar said:
> > Dear all,
> > Now, I know that it doesn't sound good from the subject, but hear me
> > out :).  I have a web application where users can update a record
> > and then submit a form to save that to the database.
> >
> > I've had a request to check so that if the user navigates away from 
> > the page before saving the data, he'll be told that he's leaving the
> >  page and be given the option of going back.
> >
> > Now, I've got most of this written:  I've got a global variable
> > called beenChanged that can be true or false and this is set to true
> > any time that a form field is selected.  I've then set the following
> > functions:
> >
> > // ====================================
> >
> > function checkPageChanged()
> > {
> >   if (beenChanged)
> >   {
> >     return confirm("You have changed this page and have not saved"
> > 				   + " those changes.\n"
> >     		 	        + "Are you sure you want to leave this page?\n"
> > 				   + "(OK to continue, Cancel to return to the page)");
> >   } // end if
> >   else return true;
> > } // end function checkPageChanged()
> >
> > // ====================================
> >
> > But I'm not sure how to stop the page getting unloaded if the user
> > presses cancel.  I'm currently using <body onunload="return
> > checkPageChanged();"> but this isn't working.
> >
> > Any ideas?
> >
> > Cheers,
> > Raj.
> > --
> > Rajnish Bhaskar, Technical officer
> > r.bhaskar(at)educ.gla.ac.uk, http://lordofthemoon.com
> > IT Education Unit, University of Glasgow
> > http://www.iteu.gla.ac.uk/
> > --
> > Tourist, Rincewind decided, meant 'idiot'.
> >       -- (Terry Pratchett, The Colour of Magic)
> 
> 
> 
> Ches
> 
> 

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA

This page is part of a preserved archive of archives.hwg.org. The site is no longer active and its content is not maintained. For enquiries about this archive, write to archive(at)iwanet.org.