Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 11th Jun 2013, 11:35 PM   #1
Active Warrior
War Room Member
 
Join Date: 2010
Location: Central New Jersey
Posts: 42
Thanks: 1
Thanked 2 Times in 2 Posts
Arrow
Why's my exitpop triggered by optin submit
Share on: 
fb share twitter share gplus share more share

Hi, I tried to put this exit pop on my WP site, but there is an entrance optin pop already there. When you try to opt in and hit submit it triggers the exit pop. Anyone know how I can fix this so it does not appear when someone tries to optin? This is the js code;
// Using \n breaks the lines and use \' for single quotes
var myMessage = '>>>WAIT! Before You Go<<< \n\n************************* \n\nClick CANCEL for\nSPECIAL OFFER ACCESS \n\n*************************';
var specialOffer = 'http://www.reikihealinghomestudy.com/trial';

function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}
function addClickEvent(a, i, func) {
if (typeof a[i].onclick != 'function') {
a[i].onclick = func;
}
}
var theDiv = '<div style="display:block; width:100%; height:100%; position:absolute; background:#FFFFFF; margin-top:0px; margin-left:0px;" align="center">';
theDiv = theDiv + '<iframe src="' + specialOffer + '" width="100%" height="100%" align="middle" frameborder="0"></iframe>';
theDiv = theDiv + '</div>';
theBody = document.body;
if (!theBody) {
theBody = document.getElementById("body");
if (!theBody) {
theBody = document.getElementsByTagName("body")[0];
}
}
var StopExit = false;
function UnPopIt() { };
function DisplayPop() {
if (StopExit == false) {
window.scrollTo(0, 0);
StopExit = true;
window.onbeforeunload = UnPopIt;
divtag = document.createElement("div");
divtag.style.position = "absolute";
divtag.style.width = "100%";
divtag.style.height = "100%";
divtag.style.zIndex = "99";
divtag.style.left = "0px";
divtag.style.top = "0px";
divtag.innerHTML = theDiv;
theBody.innerHTML = "";
theBody.topMargin = "0px";
theBody.rightMargin = "0px";
theBody.bottomMargin = "0px";
theBody.leftMargin = "0px";
theBody.style.overflow = "hidden";
theBody.appendChild(divtag);
return myMessage;
}
}
var a = document.getElementsByTagName('A');
for (var i = 0; i < a.length; i++) {
if (a[i].target !== '_blank') {
addClickEvent(a, i,
function() {
StopExit = true;
});
} else {
addClickEvent(a, i,
function() {
StopExit = false;
});
}
}
disablelinksfunc = function() {
var a = document.getElementsByTagName('A');
for (var i = 0; i < a.length; i++) {
if (a[i].target !== '_blank') {
addClickEvent(a, i,
function() {
StopExit = true;
});
} else {
addClickEvent(a, i,
function() {
StopExit = false;
});
}
}
}
addLoadEvent(disablelinksfunc);
disableformsfunc = function() {
var f = document.getElementsByTagName('FORM');
for (var i = 0; i < f.length; i++) {
if (!f[i].onclick) {
f[i].onclick = function() {
StopExit = true;
}
} else if (!f[i].onsubmit) {
f[i].onsubmit = function() {
StopExit = true;
}
}
}
}
addLoadEvent(disableformsfunc);
window.onbeforeunload = DisplayPop;

Suzanne7557 is offline  
Unread 12th Jun 2013, 04:45 AM   #2
ResponsiveDesignTest.Net
Registered Member
 
Michael71's Avatar
 
Join Date: 2011
Location: Rostock, Germany
Posts: 829
Thanks: 106
Thanked 225 Times in 194 Posts
Default
Re: Why's my exitpop triggered by optin submit
Share on: 
fb share twitter share gplus share more share

Please use the BBCodes for CODE...

The reason your ExitPopup is fired because when you hit the submit button the site gets realoded.

The line

Code:
window.onbeforeunload = DisplayPop;
is "responsible" for that.

If you would use AJAX to submit your form this would not happen

HTML/CSS/jQuery/ZURB Foundation/Twitter Bootstrap/Wordpress/Frontend Performance Optimizing
---
Need HTML/CSS help? Skype: microcosmic - Test Your Responsive Design - InternetCookies.eu
Michael71 is offline  
Unread 12th Jun 2013, 10:46 PM   #3
Social Apps Made Easy
War Room Member
 
FirstSocialApps's Avatar
 
Join Date: 2012
Location: Mooresville, NC
Posts: 913
Thanks: 231
Thanked 259 Times in 213 Posts
Default
Re: Why's my exitpop triggered by optin submit
Share on: 
fb share twitter share gplus share more share

onbeforeunload fires when the page changes. When they are submitting the form the page is unloading as it is changing, hence onbeforeunload fires.

FirstSocialApps is offline  
Closed Thread


Bookmarks

Tags
exitpop, optin, submit, triggered


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 07:18 AM.