<?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: Easy Javascript/AJAX Exit Pop up script &#8211; Creates div overlay on page exit</title>
	<atom:link href="http://www.andysowards.com/blog/tutorials/easy-javascriptajax-exit-pop-up-script-creates-div-overlay-on-page-exit/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.andysowards.com/blog/tutorials/easy-javascriptajax-exit-pop-up-script-creates-div-overlay-on-page-exit/</link>
	<description>Professional Web Design, Freelancer, Tech, Development, Programming, Gadgets, Life, Hacks, Downloads, Math and being a Web 2.0 Hipster?</description>
	<lastBuildDate>Thu, 11 Mar 2010 21:38:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Mark</title>
		<link>http://www.andysowards.com/blog/tutorials/easy-javascriptajax-exit-pop-up-script-creates-div-overlay-on-page-exit/#comment-5160</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Thu, 04 Mar 2010 21:17:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.andysowards.com/blog/?p=148#comment-5160</guid>
		<description>Thank you Andy.  This is a great script.  A jQuery version would be amazing!  Please, please post that as soon as you are able.  

Would really love to have a similar script with no alert and a modal window, but I will try to tackle that myself, let you know how it goes.  Thanks again for sharing with the rest of the community.  And please do that jQuery version!  Best.</description>
		<content:encoded><![CDATA[<p>Thank you Andy.  This is a great script.  A jQuery version would be amazing!  Please, please post that as soon as you are able.  </p>
<p>Would really love to have a similar script with no alert and a modal window, but I will try to tackle that myself, let you know how it goes.  Thanks again for sharing with the rest of the community.  And please do that jQuery version!  Best.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy Sowards</title>
		<link>http://www.andysowards.com/blog/tutorials/easy-javascriptajax-exit-pop-up-script-creates-div-overlay-on-page-exit/#comment-5046</link>
		<dc:creator>Andy Sowards</dc:creator>
		<pubDate>Fri, 19 Feb 2010 20:50:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.andysowards.com/blog/?p=148#comment-5046</guid>
		<description>Here is an updated version of the cookie script previously mentioned -----
-------------------------------------&gt;





//DO NOT EDIT BELOW This LINE (Unless of course your Savvy!)
------------------------------

var exp = 1;   // the number at the left reflects the number of days for the
cookie to last
               // modify it according to your needs

var running = false
var endTime = null
var timerID = null
function startTimer() {
    running = true
    now = new Date()
    now = now.getTime()
    endTime = now + (1000 * 60 * 1) // change last multiple for the number
of minutes , make sure it matches with set timeout below
    showCountDown()
}
function showCountDown() {
    var now = new Date()
    now = now.getTime()
    if (endTime - now &lt;= 0) {
        stopTimer()

    } else {
        var delta = new Date(endTime - now)
        var theMin = delta.getMinutes()
        var theSec = delta.getSeconds()
        var theTime = theMin
        theTime += ((theSec &lt; 10) ? &quot;:0&quot; : &quot;:&quot;) + theSec
        document.forms[0].timerDisplay.value = theTime //calls the time to
display in form input with &quot;theTime&quot; id
        if (running) {
            timerID = setTimeout(&quot;showCountDown()&quot;,1000)
        }
    }
}
function newCookie(name,value,days) {
 if (days) {
   var date = new Date();
   date.setTime(date.getTime()+(days*24*60*60*1000));
   var expires = &quot;; expires=&quot;+date.toGMTString(); }
   else var expires = &quot;&quot;;
   document.cookie = name+&quot;=&quot;+value+expires+&quot;; path=/&quot;; }

function readCookie(name) {
   var nameSG = name + &quot;=&quot;;
   var ca = document.cookie.split(&#039;;&#039;);
  for(var i=0; i&lt;ca.length; i++) {
    var c = ca[i];
    while (c.charAt(0)==&#039; &#039;) c = c.substring(1,c.length);
  if (c.indexOf(nameSG) == 0) return c.substring(nameSG.length,c.length); }
    return null; }

window.onload = function(){
// this is where we start our journey...
createExitPop();
}// end function onunload

function ajaxGET(divId, page, effect)
{
     var xmlHttp;
     try
    {
         // Firefox, Opera 8.0+, Safari
         xmlHttp=new XMLHttpRequest();
    }
     catch(e)
    {
         // Internet Explorer
         try
         {
              xmlHttp=new ActiveXObject(&quot;Msxml2.XMLHTTP&quot;);
         }
         catch(e)
          {
               try
               {
                    xmlHttp=new ActiveXObject(&quot;Microsoft.XMLHTTP&quot;);
               }
               catch(e)
             {
                    alert(&quot;Your browser does not support AJAX!&quot;);
                  return false;
             }
         }
     }

    xmlHttp.onreadystatechange=function()
     {
         if(xmlHttp.readyState==4)
          {
               if(effect == &#039;collapse&#039;) {
document.getElementById(divId).style.display=&#039;none&#039;; }
               else                     {
document.getElementById(divId).innerHTML=xmlHttp.responseText; }
         }
    }
     xmlHttp.open(&quot;GET&quot;,page,true);
    xmlHttp.send(null);
}

function delayedRedirect(){
    window.location = &quot;/finaloffer.html&quot; // this is where you specify your
3rd (well technically second page), sorry you missed the sale or new offer
page
}

function createExitPop()
{
var theBody = document.getElementsByTagName(&#039;body&#039;)[0];
var newdiv = document.createElement(&#039;div&#039;);
 newdiv.setAttribute(&#039;id&#039;,&#039;ExitDiv&#039;);
theBody.setAttribute(&#039;id&#039;,&#039;body&#039;);
newdiv.setAttribute(&#039;style&#039;, &#039;width: 100%; height: 100%;&#039;);
 // put div on page
theBody.appendChild(newdiv);
 //add exit pop to page (contents are from your exit.php(or whatever you
named it) page)
document.getElementById(&#039;ExitDiv&#039;).value = ajaxGET(&#039;ExitDiv&#039;, ExitPopURL);
 // style exit pop to resemble its own page
document.getElementById(&#039;ExitDiv&#039;).style.display = &quot;none&quot;;
document.getElementById(&#039;ExitDiv&#039;).style.top = &#039;0px&#039;;
document.getElementById(&#039;ExitDiv&#039;).style.left = &#039;0px&#039;;
document.getElementById(&#039;ExitDiv&#039;).style.position = &#039;relative&#039;;
document.getElementById(&#039;ExitDiv&#039;).style.backgroundColor = &#039;#FFFFFF&#039;;
}// end createExitPop

isExit = true;

function ExitPop(isExit) {
if(isExit != false) {
isExit=false;
isPop = true;
 var bodyTag = document.getElementById?
document.getElementsByTagName(&quot;BODY&quot;)[0] : document.body;
 // add id=&quot;body&quot; so that it can be referenced.
bodyTag.setAttribute(&quot;id&quot;, &quot;body&quot;);
//replace body text with exit pop
bodyTag.innerHTML = document.getElementById(&#039;ExitDiv&#039;).innerHTML;
setTimeout(&#039;delayedRedirect()&#039;, 60000); //set timeout for second page( time
in milisecs ie 60000=60 secs
window.startTimer(); // starts the timer on exit
return AlertBox;
 } // end if
}// end function

window.onbeforeunload = function(){
 // Lay down an exit pop!!
var num = readCookie(&#039;celeb1&#039;)
  if (num &lt; 1) {
  newCookie(&#039;celeb1&#039;,&#039;testcookie1&#039;, exp);
  return ExitPop(isExit);

}

}// end function onunload</description>
		<content:encoded><![CDATA[<p>Here is an updated version of the cookie script previously mentioned &#8212;&#8211;<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-></p>
<p>//DO NOT EDIT BELOW This LINE (Unless of course your Savvy!)<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>var exp = 1;   // the number at the left reflects the number of days for the<br />
cookie to last<br />
               // modify it according to your needs</p>
<p>var running = false<br />
var endTime = null<br />
var timerID = null<br />
function startTimer() {<br />
    running = true<br />
    now = new Date()<br />
    now = now.getTime()<br />
    endTime = now + (1000 * 60 * 1) // change last multiple for the number<br />
of minutes , make sure it matches with set timeout below<br />
    showCountDown()<br />
}<br />
function showCountDown() {<br />
    var now = new Date()<br />
    now = now.getTime()<br />
    if (endTime &#8211; now <= 0) {<br />
        stopTimer()</p>
<p>    } else {<br />
        var delta = new Date(endTime &#8211; now)<br />
        var theMin = delta.getMinutes()<br />
        var theSec = delta.getSeconds()<br />
        var theTime = theMin<br />
        theTime += ((theSec < 10) ? &#8220;:0&#8243; : &#8220;:&#8221;) + theSec<br />
        document.forms[0].timerDisplay.value = theTime //calls the time to<br />
display in form input with &#8220;theTime&#8221; id<br />
        if (running) {<br />
            timerID = setTimeout(&#8220;showCountDown()&#8221;,1000)<br />
        }<br />
    }<br />
}<br />
function newCookie(name,value,days) {<br />
 if (days) {<br />
   var date = new Date();<br />
   date.setTime(date.getTime()+(days*24*60*60*1000));<br />
   var expires = &#8220;; expires=&#8221;+date.toGMTString(); }<br />
   else var expires = &#8220;&#8221;;<br />
   document.cookie = name+&#8221;=&#8221;+value+expires+&#8221;; path=/&#8221;; }</p>
<p>function readCookie(name) {<br />
   var nameSG = name + &#8220;=&#8221;;<br />
   var ca = document.cookie.split(&#8216;;&#8217;);<br />
  for(var i=0; i<ca.length; i++) {<br />
    var c = ca[i];<br />
    while (c.charAt(0)==&#8217; &#8216;) c = c.substring(1,c.length);<br />
  if (c.indexOf(nameSG) == 0) return c.substring(nameSG.length,c.length); }<br />
    return null; }</p>
<p>window.onload = function(){<br />
// this is where we start our journey&#8230;<br />
createExitPop();<br />
}// end function onunload</p>
<p>function ajaxGET(divId, page, effect)<br />
{<br />
     var xmlHttp;<br />
     try<br />
    {<br />
         // Firefox, Opera 8.0+, Safari<br />
         xmlHttp=new XMLHttpRequest();<br />
    }<br />
     catch(e)<br />
    {<br />
         // Internet Explorer<br />
         try<br />
         {<br />
              xmlHttp=new ActiveXObject(&#8220;Msxml2.XMLHTTP&#8221;);<br />
         }<br />
         catch(e)<br />
          {<br />
               try<br />
               {<br />
                    xmlHttp=new ActiveXObject(&#8220;Microsoft.XMLHTTP&#8221;);<br />
               }<br />
               catch(e)<br />
             {<br />
                    alert(&#8220;Your browser does not support AJAX!&#8221;);<br />
                  return false;<br />
             }<br />
         }<br />
     }</p>
<p>    xmlHttp.onreadystatechange=function()<br />
     {<br />
         if(xmlHttp.readyState==4)<br />
          {<br />
               if(effect == &#8216;collapse&#8217;) {<br />
document.getElementById(divId).style.display=&#8217;none&#8217;; }<br />
               else                     {<br />
document.getElementById(divId).innerHTML=xmlHttp.responseText; }<br />
         }<br />
    }<br />
     xmlHttp.open(&#8220;GET&#8221;,page,true);<br />
    xmlHttp.send(null);<br />
}</p>
<p>function delayedRedirect(){<br />
    window.location = &#8220;/finaloffer.html&#8221; // this is where you specify your<br />
3rd (well technically second page), sorry you missed the sale or new offer<br />
page<br />
}</p>
<p>function createExitPop()<br />
{<br />
var theBody = document.getElementsByTagName(&#8216;body&#8217;)[0];<br />
var newdiv = document.createElement(&#8216;div&#8217;);<br />
 newdiv.setAttribute(&#8216;id&#8217;,'ExitDiv&#8217;);<br />
theBody.setAttribute(&#8216;id&#8217;,'body&#8217;);<br />
newdiv.setAttribute(&#8217;style&#8217;, &#8216;width: 100%; height: 100%;&#8217;);<br />
 // put div on page<br />
theBody.appendChild(newdiv);<br />
 //add exit pop to page (contents are from your exit.php(or whatever you<br />
named it) page)<br />
document.getElementById(&#8216;ExitDiv&#8217;).value = ajaxGET(&#8216;ExitDiv&#8217;, ExitPopURL);<br />
 // style exit pop to resemble its own page<br />
document.getElementById(&#8216;ExitDiv&#8217;).style.display = &#8220;none&#8221;;<br />
document.getElementById(&#8216;ExitDiv&#8217;).style.top = &#8216;0px&#8217;;<br />
document.getElementById(&#8216;ExitDiv&#8217;).style.left = &#8216;0px&#8217;;<br />
document.getElementById(&#8216;ExitDiv&#8217;).style.position = &#8216;relative&#8217;;<br />
document.getElementById(&#8216;ExitDiv&#8217;).style.backgroundColor = &#8216;#FFFFFF&#8217;;<br />
}// end createExitPop</p>
<p>isExit = true;</p>
<p>function ExitPop(isExit) {<br />
if(isExit != false) {<br />
isExit=false;<br />
isPop = true;<br />
 var bodyTag = document.getElementById?<br />
document.getElementsByTagName(&#8220;BODY&#8221;)[0] : document.body;<br />
 // add id=&#8221;body&#8221; so that it can be referenced.<br />
bodyTag.setAttribute(&#8220;id&#8221;, &#8220;body&#8221;);<br />
//replace body text with exit pop<br />
bodyTag.innerHTML = document.getElementById(&#8216;ExitDiv&#8217;).innerHTML;<br />
setTimeout(&#8216;delayedRedirect()&#8217;, 60000); //set timeout for second page( time<br />
in milisecs ie 60000=60 secs<br />
window.startTimer(); // starts the timer on exit<br />
return AlertBox;<br />
 } // end if<br />
}// end function</p>
<p>window.onbeforeunload = function(){<br />
 // Lay down an exit pop!!<br />
var num = readCookie(&#8216;celeb1&#8242;)<br />
  if (num < 1) {<br />
  newCookie(&#8216;celeb1&#8242;,&#8217;testcookie1&#8242;, exp);<br />
  return ExitPop(isExit);</p>
<p>}</p>
<p>}// end function onunload</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: will</title>
		<link>http://www.andysowards.com/blog/tutorials/easy-javascriptajax-exit-pop-up-script-creates-div-overlay-on-page-exit/#comment-5017</link>
		<dc:creator>will</dc:creator>
		<pubDate>Mon, 15 Feb 2010 20:19:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.andysowards.com/blog/?p=148#comment-5017</guid>
		<description>hey andy i did some more revisions...i am using the script for affiliate sales, as i am guessing most ppl who need this are...so what i did was make a trigger when they leave the page to start a timed redirect with a counter....this way you can offer a buyer a special and give them a time limit and then redirect them to an alternate page if time elapses...should really increase sales and with the cookies set you can honestly tell them this is a one time offer....  

on the 3rd page when they miss the offer maybe leave an email, b/c ppl will email when they know you are serious that it was a one time offer...they are more likely to take quick action and you appear more than just another pop up marketer, but rather offering a true discount</description>
		<content:encoded><![CDATA[<p>hey andy i did some more revisions&#8230;i am using the script for affiliate sales, as i am guessing most ppl who need this are&#8230;so what i did was make a trigger when they leave the page to start a timed redirect with a counter&#8230;.this way you can offer a buyer a special and give them a time limit and then redirect them to an alternate page if time elapses&#8230;should really increase sales and with the cookies set you can honestly tell them this is a one time offer&#8230;.  </p>
<p>on the 3rd page when they miss the offer maybe leave an email, b/c ppl will email when they know you are serious that it was a one time offer&#8230;they are more likely to take quick action and you appear more than just another pop up marketer, but rather offering a true discount</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy Sowards</title>
		<link>http://www.andysowards.com/blog/tutorials/easy-javascriptajax-exit-pop-up-script-creates-div-overlay-on-page-exit/#comment-5002</link>
		<dc:creator>Andy Sowards</dc:creator>
		<pubDate>Sun, 14 Feb 2010 00:09:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.andysowards.com/blog/?p=148#comment-5002</guid>
		<description>Hey Guys, Just wanted to share with you guys an addition to this script - A Visitor of the site put together an addition to this script that allows you to set a cookie - Possibly you can use that cookie to prevent the popup showing for people who have visited the site before, or who have visited in the past week or however many days you would like to set it for.

You can find the script below:

//DO NOT EDIT BELOW This LINE (Unless of course your Savvy!) ------------------------------

var exp = 1;   // the number at the left reflects the number of days for the cookie to last
               // modify it according to your needs

function newCookie(name,value,days) {
 if (days) {
   var date = new Date();
   date.setTime(date.getTime()+(days*24*60*60*1000));
   var expires = &quot;; expires=&quot;+date.toGMTString(); }
   else var expires = &quot;&quot;;
   document.cookie = name+&quot;=&quot;+value+expires+&quot;; path=/&quot;; }

function readCookie(name) {
   var nameSG = name + &quot;=&quot;;
   var ca = document.cookie.split(&#039;;&#039;);
  for(var i=0; i&lt;ca.length; i++) {
    var c = ca[i];
    while (c.charAt(0)==&#039; &#039;) c = c.substring(1,c.length);
  if (c.indexOf(nameSG) == 0) return c.substring(nameSG.length,c.length); }
    return null; }

window.onload = function(){
    // this is where we start our journey...
    createExitPop();
}// end function onunload

function ajaxGET(divId, page, effect) 
{ 
     var xmlHttp; 
     try 
    { 
         // Firefox, Opera 8.0+, Safari 
         xmlHttp=new XMLHttpRequest(); 
    } 
     catch(e)   
    { 
         // Internet Explorer 
         try 
         { 
              xmlHttp=new ActiveXObject(&quot;Msxml2.XMLHTTP&quot;); 
         } 
         catch(e)   
          { 
               try 
               { 
                    xmlHttp=new ActiveXObject(&quot;Microsoft.XMLHTTP&quot;); 
               } 
               catch(e)   
             {      
                    alert(&quot;Your browser does not support AJAX!&quot;); 
                  return false; 
             } 
         } 
     } 
      
    xmlHttp.onreadystatechange=function() 
     { 
         if(xmlHttp.readyState==4) 
          { 
               if(effect == &#039;collapse&#039;) { document.getElementById(divId).style.display=&#039;none&#039;; } 
               else                     { document.getElementById(divId).innerHTML=xmlHttp.responseText; } 
         } 
    } 
     xmlHttp.open(&quot;GET&quot;,page,true); 
    xmlHttp.send(null); 
}

function createExitPop()
{
    var theBody = document.getElementsByTagName(&#039;body&#039;)[0]; 
    var newdiv = document.createElement(&#039;div&#039;);
    newdiv.setAttribute(&#039;id&#039;,&#039;ExitDiv&#039;);
    theBody.setAttribute(&#039;id&#039;,&#039;body&#039;);
    newdiv.setAttribute(&#039;style&#039;, &#039;width: 100%; height: 100%;&#039;);
    
        // put div on page
        theBody.appendChild(newdiv);
    
        //add exit pop to page (contents are from your exit.php(or whatever you named it) page)
        document.getElementById(&#039;ExitDiv&#039;).value = ajaxGET(&#039;ExitDiv&#039;, ExitPopURL);
    
    // style exit pop to resemble its own page
    document.getElementById(&#039;ExitDiv&#039;).style.display = &quot;none&quot;; 
    document.getElementById(&#039;ExitDiv&#039;).style.top = &#039;0px&#039;; 
    document.getElementById(&#039;ExitDiv&#039;).style.left = &#039;0px&#039;; 
    document.getElementById(&#039;ExitDiv&#039;).style.position = &#039;relative&#039;; 
    document.getElementById(&#039;ExitDiv&#039;).style.backgroundColor = &#039;#FFFFFF&#039;;
    
}// end createExitPop

isExit = true;

function ExitPop(isExit) {
        if(isExit != false)    {
            isExit=false;
            isPop = true;
            
            var bodyTag = document.getElementById? document.getElementsByTagName(&quot;BODY&quot;)[0] : document.body;
            
            // add id=&quot;body&quot; so that it can be referenced.
            bodyTag.setAttribute(&quot;id&quot;, &quot;body&quot;);
            
            //replace body text with exit pop
            bodyTag.innerHTML = document.getElementById(&#039;ExitDiv&#039;).innerHTML;
            return AlertBox;
        } // end if
    }// end function

window.onbeforeunload = function(){
        
        // Lay down an exit pop!!
        var num = readCookie(&#039;celeb1&#039;)
  if (num &lt; 1) { 
  newCookie(&#039;celeb1&#039;,&#039;testcookie1&#039;, exp);
  return ExitPop(isExit);
}

    
}// end function onunload




//-------------------------
SCRIPT ENDED ABOVE


Thanks everyone for your contributions, If you have an addition to this script leave it here in the comments or send me an email! Thanks!</description>
		<content:encoded><![CDATA[<p>Hey Guys, Just wanted to share with you guys an addition to this script &#8211; A Visitor of the site put together an addition to this script that allows you to set a cookie &#8211; Possibly you can use that cookie to prevent the popup showing for people who have visited the site before, or who have visited in the past week or however many days you would like to set it for.</p>
<p>You can find the script below:</p>
<p>//DO NOT EDIT BELOW This LINE (Unless of course your Savvy!) &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>var exp = 1;   // the number at the left reflects the number of days for the cookie to last<br />
               // modify it according to your needs</p>
<p>function newCookie(name,value,days) {<br />
 if (days) {<br />
   var date = new Date();<br />
   date.setTime(date.getTime()+(days*24*60*60*1000));<br />
   var expires = &quot;; expires=&quot;+date.toGMTString(); }<br />
   else var expires = &quot;&quot;;<br />
   document.cookie = name+&quot;=&quot;+value+expires+&quot;; path=/&quot;; }</p>
<p>function readCookie(name) {<br />
   var nameSG = name + &quot;=&quot;;<br />
   var ca = document.cookie.split(&#8216;;&#8217;);<br />
  for(var i=0; i&lt;ca.length; i++) {<br />
    var c = ca[i];<br />
    while (c.charAt(0)==&#8217; &#8216;) c = c.substring(1,c.length);<br />
  if (c.indexOf(nameSG) == 0) return c.substring(nameSG.length,c.length); }<br />
    return null; }</p>
<p>window.onload = function(){<br />
    // this is where we start our journey&#8230;<br />
    createExitPop();<br />
}// end function onunload</p>
<p>function ajaxGET(divId, page, effect)<br />
{<br />
     var xmlHttp;<br />
     try<br />
    {<br />
         // Firefox, Opera 8.0+, Safari<br />
         xmlHttp=new XMLHttpRequest();<br />
    }<br />
     catch(e)<br />
    {<br />
         // Internet Explorer<br />
         try<br />
         {<br />
              xmlHttp=new ActiveXObject(&quot;Msxml2.XMLHTTP&quot;);<br />
         }<br />
         catch(e)<br />
          {<br />
               try<br />
               {<br />
                    xmlHttp=new ActiveXObject(&quot;Microsoft.XMLHTTP&quot;);<br />
               }<br />
               catch(e)<br />
             {<br />
                    alert(&quot;Your browser does not support AJAX!&quot;);<br />
                  return false;<br />
             }<br />
         }<br />
     } </p>
<p>    xmlHttp.onreadystatechange=function()<br />
     {<br />
         if(xmlHttp.readyState==4)<br />
          {<br />
               if(effect == &#8216;collapse&#8217;) { document.getElementById(divId).style.display=&#8217;none&#8217;; }<br />
               else                     { document.getElementById(divId).innerHTML=xmlHttp.responseText; }<br />
         }<br />
    }<br />
     xmlHttp.open(&quot;GET&quot;,page,true);<br />
    xmlHttp.send(null);<br />
}</p>
<p>function createExitPop()<br />
{<br />
    var theBody = document.getElementsByTagName(&#8216;body&#8217;)[0];<br />
    var newdiv = document.createElement(&#8216;div&#8217;);<br />
    newdiv.setAttribute(&#8216;id&#8217;,'ExitDiv&#8217;);<br />
    theBody.setAttribute(&#8216;id&#8217;,'body&#8217;);<br />
    newdiv.setAttribute(&#8217;style&#8217;, &#8216;width: 100%; height: 100%;&#8217;);</p>
<p>        // put div on page<br />
        theBody.appendChild(newdiv);</p>
<p>        //add exit pop to page (contents are from your exit.php(or whatever you named it) page)<br />
        document.getElementById(&#8216;ExitDiv&#8217;).value = ajaxGET(&#8216;ExitDiv&#8217;, ExitPopURL);</p>
<p>    // style exit pop to resemble its own page<br />
    document.getElementById(&#8216;ExitDiv&#8217;).style.display = &quot;none&quot;;<br />
    document.getElementById(&#8216;ExitDiv&#8217;).style.top = &#8216;0px&#8217;;<br />
    document.getElementById(&#8216;ExitDiv&#8217;).style.left = &#8216;0px&#8217;;<br />
    document.getElementById(&#8216;ExitDiv&#8217;).style.position = &#8216;relative&#8217;;<br />
    document.getElementById(&#8216;ExitDiv&#8217;).style.backgroundColor = &#8216;#FFFFFF&#8217;;</p>
<p>}// end createExitPop</p>
<p>isExit = true;</p>
<p>function ExitPop(isExit) {<br />
        if(isExit != false)    {<br />
            isExit=false;<br />
            isPop = true;</p>
<p>            var bodyTag = document.getElementById? document.getElementsByTagName(&quot;BODY&quot;)[0] : document.body;</p>
<p>            // add id=&quot;body&quot; so that it can be referenced.<br />
            bodyTag.setAttribute(&quot;id&quot;, &quot;body&quot;);</p>
<p>            //replace body text with exit pop<br />
            bodyTag.innerHTML = document.getElementById(&#8216;ExitDiv&#8217;).innerHTML;<br />
            return AlertBox;<br />
        } // end if<br />
    }// end function</p>
<p>window.onbeforeunload = function(){</p>
<p>        // Lay down an exit pop!!<br />
        var num = readCookie(&#8216;celeb1&#8242;)<br />
  if (num &lt; 1) {<br />
  newCookie(&#8216;celeb1&#8242;,&#8217;testcookie1&#8242;, exp);<br />
  return ExitPop(isExit);<br />
}</p>
<p>}// end function onunload</p>
<p>//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
SCRIPT ENDED ABOVE</p>
<p>Thanks everyone for your contributions, If you have an addition to this script leave it here in the comments or send me an email! Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy Sowards</title>
		<link>http://www.andysowards.com/blog/tutorials/easy-javascriptajax-exit-pop-up-script-creates-div-overlay-on-page-exit/#comment-4931</link>
		<dc:creator>Andy Sowards</dc:creator>
		<pubDate>Sat, 06 Feb 2010 23:40:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.andysowards.com/blog/?p=148#comment-4931</guid>
		<description>@Wallace Kline - Oh Great! So you are going to give the $67 to me right? LOL JK (Feel free to donate of course!)

No worries! Thanks for the constructive criticism - This script has been very popular and receives a lot of use - and It is over 1 year old now, so I will soon be re-building this post to be easier to follow, and probably building a jQuery version of this script as well so it will be even easier to use - I just haven&#039;t had a chance to do that yet! Thanks though for your kind words :).</description>
		<content:encoded><![CDATA[<p>@Wallace Kline &#8211; Oh Great! So you are going to give the $67 to me right? LOL JK (Feel free to donate of course!)</p>
<p>No worries! Thanks for the constructive criticism &#8211; This script has been very popular and receives a lot of use &#8211; and It is over 1 year old now, so I will soon be re-building this post to be easier to follow, and probably building a jQuery version of this script as well so it will be even easier to use &#8211; I just haven&#8217;t had a chance to do that yet! Thanks though for your kind words <img src='http://www.andysowards.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
]]></content:encoded>
	</item>
</channel>
</rss>
