Solved

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

Posted on 2013-11-20
4
232 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
arrays and buttons with user input 2 34
Link Anchor Not working 9 51
Problem in javascript 17 32
Scroll 5 news at a time using vticker 2 13
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

696 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