この
$(document).ready(function() {
setTimeout(function() {
var __redirect_to = 'url_where_to_send';//
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 'Are you sure you want to leave this page?\n\nWait...Before you go:\n\n***************************************\n\n GET A FREE BOTTLE OF NeuroNZT\n\n***************************************\n\nTo receive your bottle FOR FREE - Click Cancel or Stay on Page below';
}
}, 500);
});
</script>
出典
2017-04-18 11:57:47
Jon
'document.location.href = URLを試してみてください;'ができますが、ユーザーによって行われたアクションを防ぐことになっていません –