<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Prototype Script onbeforeunload when leaving a page</title>
	<atom:link href="http://scoop.simplyexcited.co.uk/2007/12/14/prototype-script-onbeforeunload-when-leaving-a-page/feed/" rel="self" type="application/rss+xml" />
	<link>http://scoop.simplyexcited.co.uk/2007/12/14/prototype-script-onbeforeunload-when-leaving-a-page/</link>
	<description>Technology, Design and Outdoor</description>
	<lastBuildDate>Fri, 16 Dec 2011 10:35:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Alastair Brunton</title>
		<link>http://scoop.simplyexcited.co.uk/2007/12/14/prototype-script-onbeforeunload-when-leaving-a-page/comment-page-1/#comment-3284</link>
		<dc:creator>Alastair Brunton</dc:creator>
		<pubDate>Wed, 24 Nov 2010 10:26:47 +0000</pubDate>
		<guid isPermaLink="false">http://scoop.cheerfactory.co.uk/2007/12/14/prototype-script-onbeforeunload-when-leaving-a-page/#comment-3284</guid>
		<description>I have also done a version of this for jquery. It is available in this gist - https://gist.github.com/713450</description>
		<content:encoded><![CDATA[	<p>I have also done a version of this for jquery. It is available in this gist &#8211; <a href="https://gist.github.com/713450" rel="nofollow">https://gist.github.com/713450</a></p>
 ]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan</title>
		<link>http://scoop.simplyexcited.co.uk/2007/12/14/prototype-script-onbeforeunload-when-leaving-a-page/comment-page-1/#comment-1596</link>
		<dc:creator>Jonathan</dc:creator>
		<pubDate>Fri, 14 Mar 2008 03:52:58 +0000</pubDate>
		<guid isPermaLink="false">http://scoop.cheerfactory.co.uk/2007/12/14/prototype-script-onbeforeunload-when-leaving-a-page/#comment-1596</guid>
		<description>Thanks! The event observer was the answer I was searching for.</description>
		<content:encoded><![CDATA[	<p>Thanks! The event observer was the answer I was searching for.</p>
 ]]></content:encoded>
	</item>
	<item>
		<title>By: Anthony</title>
		<link>http://scoop.simplyexcited.co.uk/2007/12/14/prototype-script-onbeforeunload-when-leaving-a-page/comment-page-1/#comment-1139</link>
		<dc:creator>Anthony</dc:creator>
		<pubDate>Tue, 05 Feb 2008 11:43:39 +0000</pubDate>
		<guid isPermaLink="false">http://scoop.cheerfactory.co.uk/2007/12/14/prototype-script-onbeforeunload-when-leaving-a-page/#comment-1139</guid>
		<description>Nice peace of code, really usefull and easy to integrate!</description>
		<content:encoded><![CDATA[	<p>Nice peace of code, really usefull and easy to integrate!</p>
 ]]></content:encoded>
	</item>
	<item>
		<title>By: Web Design Glasgow</title>
		<link>http://scoop.simplyexcited.co.uk/2007/12/14/prototype-script-onbeforeunload-when-leaving-a-page/comment-page-1/#comment-1027</link>
		<dc:creator>Web Design Glasgow</dc:creator>
		<pubDate>Wed, 23 Jan 2008 12:32:16 +0000</pubDate>
		<guid isPermaLink="false">http://scoop.cheerfactory.co.uk/2007/12/14/prototype-script-onbeforeunload-when-leaving-a-page/#comment-1027</guid>
		<description>Alistair, thanks for posting your solution - I&#039;ve been struggling getting it to work!</description>
		<content:encoded><![CDATA[	<p>Alistair, thanks for posting your solution &#8211; I&#8217;ve been struggling getting it to work!</p>
 ]]></content:encoded>
	</item>
	<item>
		<title>By: Charles Alderman</title>
		<link>http://scoop.simplyexcited.co.uk/2007/12/14/prototype-script-onbeforeunload-when-leaving-a-page/comment-page-1/#comment-937</link>
		<dc:creator>Charles Alderman</dc:creator>
		<pubDate>Thu, 10 Jan 2008 15:47:56 +0000</pubDate>
		<guid isPermaLink="false">http://scoop.cheerfactory.co.uk/2007/12/14/prototype-script-onbeforeunload-when-leaving-a-page/#comment-937</guid>
		<description>Well, I have figured something out.  I can make it work on Safari, but I&#039;m not using Prototype&#039;s Event observe method.  Here&#039;s three different tries:

&lt;code&gt;


  this.currentFormState = $(&#039;myform&#039;).serialize(false);

  // .. do stuff

  // This Works on IE and FF, but not Safari

  Event.observe(window, &#039;beforeunload&#039;, function (e) {
      var warning = &#039;The form has changed.  Your changes will &#039;
                    + &#039;be lost if you press OK.&#039;;                      
      var newContents = $(&#039;myform&#039;).serialize(false);
      
      if ( newContents != this.currentFormState ) {
        e.returnValue = warning;
        Event.stop(e);
      }
    }.bindAsEventListener(this)
  );


  // This doesn&#039;t work at all
 
  Event.observe(window, &#039;beforeunload&#039;, function () {
      var warning = &#039;The form has changed.  Your changes will &#039;
                    + &#039;be lost if you press OK.&#039;;                      
      var newContents = $(&#039;myform&#039;).serialize(false);
      
      if ( newContents != this.currentFormState ) {
        return warning;
      }       
    }.bind(this)
  );


  // This works on IE, FF, and Safari, but it doesn&#039;t use 
  // Prototype&#039;s Event observe method

  window.onbeforeunload = function () {
    var warning = &#039;The form has changed.  Your changes will &#039;
                  + &#039;be lost if you press OK.&#039;;  
    var newContents = $(&#039;myform&#039;).serialize(false);
    if ( newContents != this.currentFormState ) {    
      return warning;
    }
  }.bind(this);


&lt;/code&gt;</description>
		<content:encoded><![CDATA[	<p>Well, I have figured something out.  I can make it work on Safari, but I&#8217;m not using Prototype&#8217;s Event observe method.  Here&#8217;s three different tries:</p>

	<p><code></code></p>


	<p>this.currentFormState = $('myform').serialize(false);</p>

	<p>// .. do stuff</p>

	<p>// This Works on IE and FF, but not Safari</p>

	<p>Event.observe(window, 'beforeunload', function (e) {<br />
var warning = 'The form has changed.  Your changes will '<br />
+ 'be lost if you press OK.';<br />
var newContents = $('myform').serialize(false);</p>

	<p>if ( newContents != this.currentFormState ) {<br />
e.returnValue = warning;<br />
Event.stop(e);<br />
}</p>
	<p>}.bindAsEventListener(this)<br />
);</p>


	<p>// This doesn't work at all</p>

	<p>Event.observe(window, 'beforeunload', function () {<br />
var warning = 'The form has changed.  Your changes will '<br />
+ 'be lost if you press OK.';<br />
var newContents = $('myform').serialize(false);</p>

	<p>if ( newContents != this.currentFormState ) {<br />
return warning;<br />
}</p>
	<p>}.bind(this)<br />
);</p>


	<p>// This works on IE, FF, and Safari, but it doesn't use<br />
// Prototype's Event observe method</p>

	<p>window.onbeforeunload = function () {<br />
var warning = 'The form has changed.  Your changes will '<br />
+ 'be lost if you press OK.';<br />
var newContents = $('myform').serialize(false);<br />
if ( newContents != this.currentFormState ) {<br />
return warning;<br />
}</p>
	<p>}.bind(this);</p>


	<p></p>
 ]]></content:encoded>
	</item>
	<item>
		<title>By: pyrat</title>
		<link>http://scoop.simplyexcited.co.uk/2007/12/14/prototype-script-onbeforeunload-when-leaving-a-page/comment-page-1/#comment-928</link>
		<dc:creator>pyrat</dc:creator>
		<pubDate>Tue, 08 Jan 2008 16:58:21 +0000</pubDate>
		<guid isPermaLink="false">http://scoop.cheerfactory.co.uk/2007/12/14/prototype-script-onbeforeunload-when-leaving-a-page/#comment-928</guid>
		<description>Yes this is right. It doesnt work on safari. If you can find a modification of this solution that works on safari I would be very grateful!

Cheers,
Alastair</description>
		<content:encoded><![CDATA[	<p>Yes this is right. It doesnt work on safari. If you can find a modification of this solution that works on safari I would be very grateful!</p>

	<p>Cheers,<br />
Alastair</p>
 ]]></content:encoded>
	</item>
	<item>
		<title>By: Charles Alderman</title>
		<link>http://scoop.simplyexcited.co.uk/2007/12/14/prototype-script-onbeforeunload-when-leaving-a-page/comment-page-1/#comment-927</link>
		<dc:creator>Charles Alderman</dc:creator>
		<pubDate>Tue, 08 Jan 2008 16:53:06 +0000</pubDate>
		<guid isPermaLink="false">http://scoop.cheerfactory.co.uk/2007/12/14/prototype-script-onbeforeunload-when-leaving-a-page/#comment-927</guid>
		<description>Very good tip.  I like this solution -- it&#039;s quick and easy.

This works well for me on IE7 and FF2, but it doesn&#039;t seem to work on Safari 2.0.4.  (Haven&#039;t installed beta 3 yet).  I get no nag message box when refreshing/exiting the page, as Safari seems to skip the beforeunload event.  I&#039;m still investigating the problem...

Thanks</description>
		<content:encoded><![CDATA[	<p>Very good tip.  I like this solution&#8212;it&#8217;s quick and easy.</p>

	<p>This works well for me on <span class="caps">IE7</span> and <span class="caps">FF2</span>, but it doesn&#8217;t seem to work on Safari 2.0.4.  (Haven&#8217;t installed beta 3 yet).  I get no nag message box when refreshing/exiting the page, as Safari seems to skip the beforeunload event.  I&#8217;m still investigating the problem&#8230;</p>

	<p>Thanks</p>
 ]]></content:encoded>
	</item>
</channel>
</rss>

