Hello, I have this exit pop redirect Javascript. It works perfectly, except I want the page to redirect immediately while the prompt for the user to stay on page or leave is still there. Does that make sense?
Making this exit pop JavaScript redirect immediately
9
Hello, I have this exit pop redirect Javascript. It works perfectly, except I want the page to redirect immediately while the prompt for the user to stay on page or leave is still there.
Does that make sense?
The script currently doesn't redirect until the user chooses to stay on page. But I have had one before that redirects immediately, even while the prompt is up.
Here is the script below. If anyone can help I would really appreciate it. Thanks.
<script language="javascript">
(function() {
setTimeout(function() {
var __redirect_to = 'http://myurl.com/';//
var _tags = ['button', 'input', 'a'], _els, _i, _i2;
for(_i in _tags) {
_els = document.getElementsByTagName(_tags[_i]);
for(_i2 in _els) {
if((_tags[_i] == 'input' && _els[_i2].type != 'button' && _els[_i2].type != 'submit' && _els[_i2].type != 'image') || _els[_i2].target == '_blank') continue;
_els[_i2].onclick = function() {window.onbeforeunload = function(){};}
}
}
window.onbeforeunload = function() {
setTimeout(function() {
window.onbeforeunload = function() {};
setTimeout(function() {
document.location.href = __redirect_to;
}, 500);
},5);
return '************************************** My Return Message ***************************';
}
}, 500);
})();
</script>
Does that make sense?
The script currently doesn't redirect until the user chooses to stay on page. But I have had one before that redirects immediately, even while the prompt is up.
Here is the script below. If anyone can help I would really appreciate it. Thanks.
<script language="javascript">
(function() {
setTimeout(function() {
var __redirect_to = 'http://myurl.com/';//
var _tags = ['button', 'input', 'a'], _els, _i, _i2;
for(_i in _tags) {
_els = document.getElementsByTagName(_tags[_i]);
for(_i2 in _els) {
if((_tags[_i] == 'input' && _els[_i2].type != 'button' && _els[_i2].type != 'submit' && _els[_i2].type != 'image') || _els[_i2].target == '_blank') continue;
_els[_i2].onclick = function() {window.onbeforeunload = function(){};}
}
}
window.onbeforeunload = function() {
setTimeout(function() {
window.onbeforeunload = function() {};
setTimeout(function() {
document.location.href = __redirect_to;
}, 500);
},5);
return '************************************** My Return Message ***************************';
}
}, 500);
})();
</script>
- samolabams
- [2] replies
- Technito
- [1] reply
- bikithalee
- [1] reply
Next Topics on Trending Feed
-
9