window.onload()在第一镜头中不会触发IE 8 [英] window.onload() is not firing with IE 8 in first shot

查看:94
本文介绍了window.onload()在第一镜头中不会触发IE 8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让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()不会触发。有人遇到这个问题吗?



这里是代码片段:

 <!DOCTYPE html PUBLIC -  // W3C // DTD XHTML 1.0 Transitional // ENhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> 
< head>
< meta http-equiv =X-UA-Compatiblecontent =IE = 8/>
< title>测试< / title>
< link rel =stylesheethref =test.csstype =text / css>< / link>
< script type =text / javascriptsrc =login.js>< / script>
< script type =text / javascriptsrc =common.js>< / script>
< script type =text / javascript>
window.onload = function()
{
//第一次拍摄时根本没有来过
}
< / script>
< / head>
< body>



然而,刷新页面似乎可以实现它。



我在这里缺少什么?

更新:

的IE插件创造了这个问题,禁用其工作正常后。感谢您的时间和答案:) 对于IE试试:

  window.onload = new function(){alert('hello');}; 


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?

here is the code snippet:

<!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?

UPDATE:

One of the IE addons created this problem, after disabling its working fine. Thanks for your time and answers :)

解决方案

For IE try:

window.onload = new function() { alert('hello');};

这篇关于window.onload()在第一镜头中不会触发IE 8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆