在 Safari 上的 window.onbeforeunload

140 views
Skip to first unread message

gugod

unread,
Dec 21, 2007, 2:25:05 AM12/21/07
to hsinchu.js
onbeforeunload 在 Safari 上的行為不太一樣。IE 與 Firefox 需要設置 event.returnValue ,但
在 Safari 上的需要傳回它:


window.onbeforeunload = function(event) {
if (!event) event = window.event; // for IE

var message = "You have something unsaved.";

if (is_safari) {
return message;
}

event.returnValue = message;
}


banan...@gmail.com

unread,
Dec 31, 2007, 9:14:11 AM12/31/07
to hsinchu.js
除 Opera 外, 我測試過 return 已經可以
Reply all
Reply to author
Forward
0 new messages