[hwg-language] Re: Stopping a user from navigating away from a document
by "Ches" <ches(at)io.com>
|
Date: |
Wed, 21 Jan 2004 08:38:59 -0600 (CST) |
To: |
<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?
Ches
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