Solved

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

Posted on 2013-11-20
4
228 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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 …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

706 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

15 Experts available now in Live!

Get 1:1 Help Now