Solved

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

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

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

724 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