• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic