问题描述
我注意到,window.onunload事件触发关闭后Page_Load事件这是没有意义的。
I have noticed that window.onunload event fires off AFTER page_load event which makes no sense.
此行为是创造我的一个问题 - 在我的unonload我清除会话,因此,如果在Page_Load前先onunload的,也有在页面上显示的错误
This behaviour is creating an issue for me - in my unonload I clear the session, so if the Page_Load first BEFORE onunload, there are errors on the page displayed.
我期望的JavaScript onunload的到炉火前的Page_Load ....是正确的假设呢?
I would expect the javascript onunload to fire BEFORE Page_Load....is that the correct assumption?
澄清:
假设我在页面Test.aspx文件,然后我点击进入相同页面的链接(比如我点击菜单上的),我观察到的是,火灾的Page_Load首先,再onunload的触发关闭。
是没有意义的。
TO CLARIFY:Let's assume I am on page test.aspx, then I click on the link that goes to the same page (say I click on a menu), what I observe is that Page_Load fires first, then onunload fires off.Makes no sense at all.
推荐答案
这是一个特定的浏览器的行为。 Chrome和FF将发送GET requst onunload的前触发,IE8将首先执行onunload的。不知道,其他的浏览器如何处理它。最好不要依赖此功能。
It's a browser-specific behaviour. Chrome and FF will send a GET requst BEFORE onunload is fired, IE8 will execute onunload first. Not sure, how the other browser handle it. Better not rely on this functionality.
这篇关于JavaScript的window.onunload打完后的Page_Load的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!