Javascript FF在document.write()之后继续旋转 函数fn(){ 写下“你好!!!”; } 点击
单击按钮后,FF继续旋转(11.0),而好像我直接调用fn(),而不将其连接到按钮,它工作正常。有人可以查看一下吗?您需要调用<代码>文档。写入调用Javascript FF在document.write()之后继续旋转 函数fn(){ 写下“你好!!!”; } 点击,javascript,Javascript,单击按钮后,FF继续旋转(11.0),而好像我直接调用fn(),而不将其连接到按钮,它工作正常。有人可以查看一下吗?您需要调用文档。写入调用文档。如果文档尚未打开,则打开。只要不使用document.close再次关闭文档,浏览器将指示页面可能会更改 <html> <head> <script type="text/javascript" > function fn() { document.write("Hello t
文档。如果文档尚未打开,则打开
。只要不使用document.close再次关闭文档,浏览器将指示页面可能会更改
<html>
<head>
<script type="text/javascript" >
function fn() {
document.write("Hello there!!!");
}
</script>
</head>
<body>
<button onclick="fn()">click</button>
</body>
</html>
谢谢..但是在我提到的第二个例子中,(在这里我直接调用fn(不点击按钮),为什么它工作良好,不调用文档。关闭?FF自上而下解释网站。当FF到达脚本时,文档仍然打开,并且“你好”将被添加到文档中。呈现完所有内容后,FF调用document.close()
implicit。这就是加载指示器逐渐消失的原因。那么在我单击按钮的另一种情况下会发生什么呢?类似的情况会发生:Firefox呈现页面->隐式调用document.close()
->您按下按钮->隐式调用document.open()
->document.write(“你好!!!”)
。在document.write()之后缺少的document.close()
会导致旋转。不过,即使调用document.close()…CMD+R,重新加载也会停止工作。
function fn() {
// implicit call to `document.open();` before document.write
document.write("Hello there!!!");
document.close();
}