Solved

confirmation box is required if the user navigating to another page with out saving the data

Posted on 2013-11-20
4
230 Views
Last Modified: 2013-12-17
i have a requirement, in my web application, web page is having many fields, if the user is trying to navigating from this page to another page with out saving , system has to pop some confirmation alert.
For Example: Changes done, you want to exit with out saving the changes Yes / No

So how my system will understand whether i did the changes in page or not? Kindly help me

i am using jsf framework
0
Comment
Question by:prabhualla
4 Comments
 
LVL 7

Expert Comment

by:dimmergeek
ID: 39662554
This will be difficult to do if you do not have a "menu-less" window.  Once I press the "back" button in my browser, you're code will now know it.
You need to create a page that has it's own navigation buttons, but even that does not prevent me from right-clicking and selecting "Bacnk"...unless you disable right-click.  Now you've totally altered my browser and I'm not sure I want to be on your site unless this is an Intranet site...
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 39662562
var somethingChanged = false;
var changesNotSaved = true;
window.onbeforeunload = function() {
     if(somethingChanged && changesNotSaved) return "Changes done, you want to exit with out saving the changes";
}

Open in new window


test page : http://jsfiddle.net/Mjh6t/
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now