FF在document.write()之后继续旋转 [英] FF keeps spinning after document.write()

查看:117
本文介绍了FF在document.write()之后继续旋转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<html>
  <head>
    <script type="text/javascript" >
       function fn() {
       document.write("Hello there!!!");
       }

    </script>
  </head>

   <body>
      <button onclick="fn()">click</button>
   </body>
</html>

点击按钮后,FF继续旋转(11.0),就像我直接调用fn一样()没有连接到按钮,它工作正常。有人可以看看这个吗?

After clicking the button , FF keeps on spinning (11.0), while as if I directly call the fn() without wiring it to the button , it works fine.Could anyone please look into this ?

推荐答案

你需要打电话给< a href =https://developer.mozilla.org/en-US/docs/DOM/document.close =noreferrer> document.close() document.write 如果文档尚未打开,则调用 document.open 。只要文档没有再次使用 document.close 关闭,浏览器就会指示页面可能会发生变化。

You need to call document.close(). document.write calls document.open if the document hasn't been opened. As long as the document isn't closed again with document.close the browser will indicate that the page is subject to change.

function fn() {
    // implicit call to `document.open();` before document.write
    document.write("Hello there!!!");
    document.close();
}

这篇关于FF在document.write()之后继续旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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