ブラウザの閉じるボタン制御したいんだけどとかいう話
友人から質問があったので、一応携帯メールで返信したけどこういう事ですかね?
jQuery使ってます。
<html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>unload test</title> <script type="text/javascript" src="./js/jquery-1.3.2.min.js"></script> <script> $(window).bind('beforeunload', function(e){ if(context.editing){ // データ編集中だけメッセージを出す return e.originalEvent.returnValue = "終了したりしますけどいいですか??"; } }); $(window).bind('unload', function(e){ // logout処理の実行 $.ajax({ url: 'logout.cgi', type: 'post' }); }); </script> </head> <body>ブラウザの閉じるボタンでログアウト処理を行うテスト。</body> </html>