Re: [Proto-Scripty] Re: event on leaving page

2013-01-10 Thread sreekala . a
I tried this code before window close.But again i get a pop up like  This 
page is asking you to confirm that you want to leave - data you have 
entered may not be saved.Two pop-ups are not needed.
window.onbeforeunload = function() {
var r=confirm(Are you sure you want to navigate away?);
if (r==false)
  {
 return false;
  }
 
 }



-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/prototype-scriptaculous/-/o0lXyGlNh4cJ.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



Re: [Proto-Scripty] Re: event on leaving page

2011-03-11 Thread Richard Quadling
On 11 March 2011 01:17, joe t. thooke...@gmail.com wrote:
 One note on TJ's post, hopefully helpful:

 You cannot CANCEL the unload event. If i understand them correctly,
 load and unload are the only native events that can't be canceled from
 scripts. You can perform other actions, but unload means the browser
 has been committed to unloading that page, regardless what else it's
 told to do at that point. The point of no return to let the user
 cancel the unload is beforeunload (handy, and a Microsoft creation,
 ironically).

 And to his point, he's correct: about the only other actions you can
 take are cleanup/garbage collection. Not that it would matter anyway
 if you create new content, the page is going bye-bye. :)

 That all comes from a painful two weeks a few years ago before i knew
 about beforeunload. Still bitter at myself over that.
 -joe t.


 On Mar 10, 9:31 am, Walter Lee Davis wa...@wdstudio.com wrote:
 On Mar 10, 2011, at 2:25 AM, T.J. Crowder wrote:

  What you can do in those functions is severely limited by modern
  browsers (for all the good reasons you can think of). You can't open
  new windows, do alerts/confirms

 Thanks. This is the part I was remembering -- someone wanted an Are
 You Sure to interrupt closing the window on a running process, and I
 mistook the answer to mean that onunload couldn't do much of anything,
 versus 'couldn't do much of anything to the current window'. That
 makes perfect sense now.

 Walter

 --
 You received this message because you are subscribed to the Google Groups 
 Prototype  script.aculo.us group.
 To post to this group, send email to prototype-scriptaculous@googlegroups.com.
 To unsubscribe from this group, send email to 
 prototype-scriptaculous+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/prototype-scriptaculous?hl=en.



Sort of related, is there a way to see ALL the events being fired by
the DOM? I used to use Borland tools on Windows and one of the tools
was a message inspector. You could target an app and watch the
messages being passed around - there were a LOT - Windows is really
chatty.

Is there a global event dispatcher that can be hooked into?

If so, how useful would this be in diagnosing issues and seeing what
events the browsers support and how the events are called?

-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



Re: [Proto-Scripty] Re: event on leaving page

2011-03-11 Thread Bertilo Wennergren
T.J. Crowder t...@crowdersoftware.com wrote:

 Yes, you can run functions using the window unload event. Example:
 http://jsbin.com/apuke4
 Open that link in a tab, click Open Window, then close the tab you
 opened the link in -- the subordinate window closes as well.

 What you can do in those functions is severely limited by modern
 browsers (for all the good reasons you can think of). You can't open
 new windows, do alerts/confirms, I think even synchronous ajax calls
 are off-limits (at least cross-browser). But you can do some useful
 things (like close subordinate windows).

Here's a limitation with beforeunload (in case someone hasn't
heard):

More of less the only thing you can do with beforeunload, is to ask
the user if he or she really wants to leave the page. A dialog
will appear, and the user can choose to abort the unloading and stay
on the page. Normally you can add your own text to this dialog, informing
why it might be wise not to leave the page. In Firefox 4 this is no longer
possible! The dialog will have the following canned text that you cannot
change (it might be in another language though):

  This page is asking you to confirm that you want to leave - data you
  have entered may not be saved.

That's what the dialog will say in Firefox 4. You can't change it, and you
can't add anything to it. If the reason for using beforeunload does not
have anything to do with entered data, or if you'd like to inform the user
precisely what kind of data would be lost, or where on the page it is to be
found, or why it's would be so bad to lose it, you're out of luck.

This is all by design.

-- 
Bertilo Wennergren
berti...@gmail.com http://bertilow.com

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



Re: [Proto-Scripty] Re: event on leaving page

2011-03-11 Thread Walter Lee Davis


On Mar 11, 2011, at 7:41 AM, Bertilo Wennergren wrote:


Here's a limitation with beforeunload (in case someone hasn't
heard):

More of less the only thing you can do with beforeunload, is to ask
the user if he or she really wants to leave the page. A dialog
will appear, and the user can choose to abort the unloading and stay
on the page. Normally you can add your own text to this dialog,  
informing
why it might be wise not to leave the page. In Firefox 4 this is no  
longer
possible! The dialog will have the following canned text that you  
cannot

change (it might be in another language though):

 This page is asking you to confirm that you want to leave - data you
 have entered may not be saved.

That's what the dialog will say in Firefox 4. You can't change it,  
and you
can't add anything to it. If the reason for using beforeunload  
does not
have anything to do with entered data, or if you'd like to inform  
the user
precisely what kind of data would be lost, or where on the page it  
is to be

found, or why it's would be so bad to lose it, you're out of luck.

This is all by design.

--
Bertilo Wennergren
berti...@gmail.com http://bertilow.com



Thanks, this is very interesting. I just tested with the following bit  
of code:


document.observe('dom:loaded',function(){
Event.observe(window,'beforeunload',function(evt){
evt.stop();
			if (confirm('Are you sure you want to close the window?')) return  
true;

});
});

In Safari, I got what I expected -- my confirm dialog blocking the  
window close. But in Firefox 3.latest, I got two dialogs. First was my  
confirm, but when I okayed that I got the second, which was more or  
less exactly the same as what you describe for FF4. I commented out  
the confirm line, and got only the one alert, but then in Safari I got  
no warning at all.


I wonder if there's any way besides browser sniffing to work around  
this double-warning?


Walter

--
You received this message because you are subscribed to the Google Groups Prototype 
 script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



Re: [Proto-Scripty] Re: event on leaving page

2011-03-11 Thread Walter Lee Davis


On Mar 11, 2011, at 7:50 PM, joe t. wrote:


Here's a sample from code that i wrote and seems to work ok (at least,
last i tested it, i no longer work there), adapted for generics:
http://pastie.org/1661648

So here's what i learned, now that my curiosity got roused...

The beforeunload event will automatically generate the prompt. If you
want to inject a custom message into that prompt (not speaking for
FF4, as i haven't tested on that with my prior code), you assign that
STRING to the event.returnValue property.

i'm pretty sure that by assigning a value to event.returnValue, the
prompt is fired. If it has no value by the time the handler returns,
the prompt does not occur.

The user is prompted with the built-in prompt, plus your custom
message.

The event will automatically cancel ITSELF if the user hits the Cancel
button of the confirmation message.

There's no need to put a confirm in the event handler yourself. That's
what would cause the double-prompt, and the confirm you generate is
ignored by the event anyway.

That's the best i can recall, anyway. i hope it helps.
-joe t.




This works really nicely in Firefox 3.latest, and does what you say --  
intermingles the custom message with the browser default message. But  
in Safari 5.latest, closing the window does nothing -- no alert of any  
kind is issued. That's why I ended up putting the confirm() in there  
in the first place -- to get Safari to do something in this event.


Walter

--
You received this message because you are subscribed to the Google Groups Prototype 
 script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



Re: [Proto-Scripty] Re: event on leaving page

2011-03-10 Thread Walter Lee Davis


On Mar 10, 2011, at 2:25 AM, T.J. Crowder wrote:


What you can do in those functions is severely limited by modern
browsers (for all the good reasons you can think of). You can't open
new windows, do alerts/confirms



Thanks. This is the part I was remembering -- someone wanted an Are  
You Sure to interrupt closing the window on a running process, and I  
mistook the answer to mean that onunload couldn't do much of anything,  
versus 'couldn't do much of anything to the current window'. That  
makes perfect sense now.


Walter

--
You received this message because you are subscribed to the Google Groups Prototype 
 script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.