Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Has anybody forund an answer-Browser window closing

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I have a form where i want this functionality:
A)If the user clicks the browser closing button(X) then he should get a pop up stating that "Do you want to save the changes before closing the window"
B)If the user clicks "yes" on the confirmation Dialog then the window should not get closed but allow him to do some other functionality on the current page.
C)The pop up Diaolg should not appear when the user is navigating to some other page from the current page.

For the above scenario A) and B) using window.onbeforeunload = function(e) is ideal.But the problem is it also pops up when the user is navigating to another page.so scenario C) fails.

I applied another solution for preventing scenario C) taking the IE properties but sceanrio B) fails here the window will definitely get closed :
function unLoadFnc()
{
if(window.screenLeft < 10004)
{
alert("Refresh Coordinate: "+window.screenLeft);
}
else
{
alert("Closing Coordinate: "+window.screenLeft);
dispConfirm();
}

I know it is asking to much in a nut shell.But please respond to this mail if you know any alternative.I would really appreciate any help.


Best Regards,
Pallavi
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ALl you have to do is work with onbeforeunload. You have to add flags to links, forms, etc. You are not going to get a perfect client application experience.

If people forget to save their data, there loss. I would do what GMAIL does and save the data to the server as a draft (with Ajax) if you really need to hold info.

Eric
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic