ãã¼ã¸é·ç§»åã«ç¢ºèªãã¤ã¢ãã°ãåºã onbeforeunload
ç·¨éä¸ã«å¥ã®ãã¼ã¸ã«é·ç§»ãããã¨ããæã«ç¢ºèªãã¤ã¢ãã°ãåºãããã
以ä¸ã®ããã« onbeforeunload ã¤ãã³ãã使ãã°OKã
window.onbeforeunload = function (e) { var e = e || window.event; // For IE and Firefox prior to version 4 if (e) { e.returnValue = 'Any string'; } // For Safari return 'Any string'; };
jQueryã®å ´å
$(window).bind('beforeunload', function(event) { return 'Any string'; });
ãã ããIEã®å ´åã¯ä»¥ä¸ã®ãããªé·ç§»ããªãaã¿ã°ã§ãonbeforeunloadãçºçãã¦ãã¾ãã
<a href="javascript:void(0);">ä¿å</a>
以ä¸ã®ããã«å¯¾å¿
var execBeforeUnload = true; $(window).bind('beforeunload', function(e) { if (execBeforeUnload) { return 'Any string'; } }); $(document).ready(function() { $('a').click(function(e) { if (e.target.href && e.target.href.indexOf("javascript") === 0) { cancelBeforeUnload(); } }); }); function cancelBeforeUnload() { execBeforeUnload = false; setTimeout(function() { execBeforeUnload = true; }, 0); }
åèï¼
window.onbeforeunload - MDC Doc Center
https://developer.mozilla.org/en/DOM/window.onbeforeunload
ãã¼ã¸ç§»ååã«ç¢ºèªãã¤ã¢ãã° - ironsJPã®ããã° - Yahoo!ããã°
http://blogs.yahoo.co.jp/irons765/6688178.html