私が使用しているスクリプトでwindow.confirmを動作させようとしていますが、動作したくないようです。何が起こるかというと、人がキャンセルを押してもコードが実行されます。悲しいことに、コードを書いた方法では、ポップアップ ボックスがクロムに表示されません。window.confirm メソッドを削除しても、ポップアップ ボックスは表示されますが、どちらを選択してもスクリプトが実行されるだけです。これがコードです。ご協力ありがとうございます。
var validNavigation = false;
function wireUpEvents() {
var dont_confirm_leave = 0; to be able to leave withou confirmation
var leave_message = 'Leaving the page will terminate your Self-Service or Kiosk session.';
function goodbye(e) {
if (!validNavigation)
function goodbye() = {
var x = window.confirm("Leaving the page will terminate your Self-Service or Kiosk session.")
if (x)
{
window.onunload=leave;
}
else {
return "" ;
}
}}
function leave() {
if (!validNavigation) {
killSession();
}
}
//set event handlers for the onbeforeunload and onunloan events
window.onbeforeunload=goodbye;
//window.onunload=leave;
}
// Wire up the events as soon as the DOM tree is ready
jQuery(document).ready(function() {
wireUpEvents();
});