Firefox中脚本标记中的async属性

时间:2012-07-16 21:43:48

标签: javascript html5 firefox asynchronous

我正在尝试在Firefox 13.0.1中测试以下代码,但它无法正常运行:

<!DOCTYPE html>
<html>
    <head>
        <title>Exercise 1</title>
        <script type="text/javascript" async src="example1.js"></script>
        <script type="text/javascript" async src="example4.js"></script>
        <script type="text/javascript" src="example3.js"></script>
    </head>
    <body>
        <p>Hello world</p>
    </body>
</html>

// example1.js:

alert("I'm the example 1");

// example3.js

alert("I'm the example 3");

// example4.js

alert("I'm the example 4");

当我打开包含上述html代码的文件时,会发生以下情况:

我编辑了我遵循的流程

  1. 首先,执行脚本“example3.js”,然后出现带有文本“我是示例3”的弹出窗口。之后,我点击弹出窗口中的确定按钮。
  2. 在第二位,执行脚本“example4.js”,然后出现带有文本“我是示例4”的弹出窗口。之后,我点击弹出窗口中的确定按钮。
  3. 在第三位,执行脚本“example1.js”,然后出现带有文本“我是示例1”的弹出窗口。之后,我点击弹出窗口中的确定按钮。
  4. 最后,应显示正文内容(带有“Hello World”文本的段落),但它不是在Firefox中,而是在Chrome中。在Firefox中,页面加载不会停止。
  5. 如果我在执行完最后一个脚本后在Firefox中打开Firebug,我会发现浏览器没有收到body元素。

    enter image description here

    我不知道我的代码是否正确或是Firefox的错误。

    谢谢。

1 个答案:

答案 0 :(得分:2)

这是firefox中已经报告的错误:https://bugzilla.mozilla.org/show_bug.cgi?id=692754

相关问题