【JavaScript】控制瀏覽器右上角關閉事件|| 離開本網頁
javascript 寫法: <script language=" javascript "> window.onbeforeunload = function() { window.event.returnValue = "Goodbye Jason !"; if (window.event.reason == false) { window.event.cancelBubble = true; } } </script> vbscript 寫法: <script language=" vbscript "> sub window_onbeforeunload() window.event.returnValue = "Goodbye Jason !" if window.event.reason = false then window.event.cancelBubble = true exit sub end if end sub </script> ps:當你要進行表單送出時總不能還出現這個離開網頁的提示框吧! 所以你還必須在表單的 Submit 按鈕特別加上一段 JavaScript 將 事件取消。 <input type="submit" value="送出" onclick=" window.document.body.onbeforeunload=null;return true; " /> onbeforeunload可以用在body、window和frameset上 <body window_onbeforeunload()> 當你在網頁中按下 F5...