var ExitPopURL = 'http://www.myDomain.com/userexit.php';
var AlertBox = "*****************************************************\n\n Stop!!\n\nBefore leaving, please give a quick survey on how we doing and share your suggestions.\n\nThanks for visiting myDomain.com.\n\n \n\n*****************************************************";
window.onload = function(){
createExitPop();
}
function ajaxGET(divId, page, effect)
{
var xmlHttp;
try
{
xmlHttp=new XMLHttpRequest();
}
catch(e)
{
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e)
{
alert("Error");
return false;
}
}
}
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
if(effect == 'collapse') { document.getElementById(divId).style.display='none'; }
else { document.getElementById(divId).innerHTML=xmlHttp.responseText; }
}
}
xmlHttp.open("GET",page,true);
xmlHttp.send(null);
}
function createExitPop()
{
var theBody = document.getElementsByTagName('body')[0];
var newdiv = document.createElement('div');
newdiv.setAttribute('id','ExitDiv');
theBody.setAttribute('id','body');
newdiv.setAttribute('style', 'width: 100%; height: 100%;');
theBody.appendChild(newdiv);
document.getElementById('ExitDiv').value = ajaxGET('ExitDiv', ExitPopURL);
document.getElementById('ExitDiv').style.display = "none";
document.getElementById('ExitDiv').style.top = '0px';
document.getElementById('ExitDiv').style.left = '0px';
document.getElementById('ExitDiv').style.position = 'relative';
document.getElementById('ExitDiv').style.backgroundColor = '#FFFFFF';
}
isExit = true;
function ExitPop(isExit) {
if(isExit != false) {
isExit=false;
isPop = true;
var bodyTag = document.getElementById? document.getElementsByTagName("BODY")[0] : document.body;
bodyTag.setAttribute("id", "body");
bodyTag.innerHTML = document.getElementById('ExitDiv').innerHTML;
return AlertBox;
}
}
window.onbeforeunload = function(){
return ExitPop(isExit);
}