window.onload() 没有在第一次使用 IE 8 时触发 [英] window.onload() is not firing with IE 8 in first shot
问题描述
我试图让我的页面在 IE 8 下正常工作,我从这里发现:http://www.masykur.web.id/post/How-to-Make-Our-Website-to-be-Ready-for-IE8.aspx也就是说,我的页面必须符合 XHTML 1.0 并且至少符合 CSS 2.1,我使我的页面和 CSS 符合只有很少的警告,但 window.onload() 仍然没有触发.有人遇到过这个问题吗?
I am trying to make my pages work correctly with IE 8, I found out from here: http://www.masykur.web.id/post/How-to-Make-Our-Website-to-be-Ready-for-IE8.aspx that, my page has to be XHTML 1.0 compliant and atleast CSS 2.1 compliant, I made my page and CSS compliant with only few warnings, but still window.onload() is not firing. Does anybody encountered this problem?
这是代码片段:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=8"/>
<title>Testing</title>
<link rel="stylesheet" href="test.css" type="text/css"></link>
<script type="text/javascript" src="login.js"></script>
<script type="text/javascript" src="common.js"></script>
<script type="text/javascript">
window.onload = function()
{
// Not coming here at all on first shot
}
</script>
</head>
<body>
.
.
.
不过刷新页面似乎可以让它工作.
However refreshing the page seems to make it work.
我在这里遗漏了什么吗?
Am I missing something here?
更新:
其中一个 IE 插件在禁用其正常工作后产生了此问题.感谢您的时间和回答:)
One of the IE addons created this problem, after disabling its working fine. Thanks for your time and answers :)
推荐答案
对于 IE 试试:
window.onload = new function() { alert('hello');};
这篇关于window.onload() 没有在第一次使用 IE 8 时触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!