当用户试图离开时,必须执行一个代码只是一个简单的调用服务器通知必须删除一个文件,它不作任何回应,但系统不'打电话。在卸载函数执行AJAX调用
$(window).unload(function(){
alert(1)
window.key = document.getElememtsByTagName('body')[0].getAttribute('key');
catcher('clearBt');//The catcher makes the AJAX call like i show below.
});
//This is the call to the server.
phone.open(method, address, true);
phone.setRequestHeader("Content-type", 'application/x-www-form-urlencoded');
phone.send(reqStr);
我尝试用onbeforeunload来,但结果是一样的......
你得到一个JavaScript错误?警报(1)后您需要分号。 – Chocula 2010-12-15 18:43:20
我没有什么多数民众赞成在问题... – hidura 2010-12-15 21:25:48