私は何時間も探していて、複数のバージョンをテストして、自分の理論をテストしています。jQueryの終了ポップアップリダイレクト?
私がしようとしているのは、alert
またはconfirm
(または何でもよい)を使用して、ユーザーが購入フォームからナビゲートしようとするとダイアログをポップアップすることです。私はちょうど彼らに "おい、代わりに、無料の相談を受けるのはなぜですか?"と尋ねたいと思います。ユーザーを「無料相談」フォームにリダイレクトします。
これは私がこれまで行ってきたことであり、正しい結果を得られないだけです。
$(window).bind('beforeunload', function(){
var pop = confirm('Are you sure you want to leave? Why not get a FREE consultation?');
if (pop) {
window.location.href('http://www.mydomain/free-consultation/');
} else {
// bye bye
}
});
$("form").submit(function() {
$(window).unbind("beforeunload");
});
注:https://bugzilla.mozilla.org/show_bug.cgi?id=588292 – Interrobang