jQuery bind beforeunload - not working with IE 9

I have a piece of code i want fired when the page closes (basically, send a 'disconnected' message to the server. The execution should be fast enough for me not to have to cancel and restart the event. Further to that, it works perfectly in Chrome, Firefox and Safari, but not in IE9 on closing the tab. If i navigate to another page in IE9, my event fires. If i close the tab, it doesn't. I tried the following to bind my code: jQuery(window).bind("beforeunload", function() { DoSomeWork(); }); i also tried replacing jQuery with $ like so: $(window).bind("beforeunload", function() { DoSomeWork(); }); Still works in Chrome, but does not work in IE. Any suggestions? I am using jquery 1.9.1 min (compressed production version).
Try using onbeforeunload

以上就是jQuery bind beforeunload - not working with IE 9的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » jQuery 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准