Javascript 在IE中,为什么document.open失败,而tempDocument.open成功?

Javascript 在IE中,为什么document.open失败,而tempDocument.open成功?,javascript,internet-explorer,iframe,Javascript,Internet Explorer,Iframe,在iframe中,动态加载内容时,顺序document.open、document.write和document.close在IE 9、10和11中失败,但在其他浏览器中成功。但是,如果我将文档分配给一个临时变量,然后执行打开,写入,关闭,IE成功。为什么会这样 (是的,我知道除了document.open/write/close,还有更好的选择,比如jquery和DOM构造,但我很好奇为什么这会失败。) 以下文件显示了该问题: index.htm <!DOCTYPE html> &

在iframe中,动态加载内容时,顺序
document.open
document.write
document.close在IE 9、10和11中失败,但在其他浏览器中成功。但是,如果我将
文档
分配给一个临时变量,然后执行
打开
写入
关闭
,IE成功。为什么会这样

(是的,我知道除了
document.open/write/close
,还有更好的选择,比如jquery和DOM构造,但我很好奇为什么这会失败。)

以下文件显示了该问题:

index.htm

<!DOCTYPE html>
<html>
<head>
    <title>Top Window</title>
</head>
<body>
<p>Top Window</p>
<div id="testDiv" style="width: 100%;">
    <iframe src="frame.htm" style="width: 100%;"></iframe>
</div>
</body>
</html>
content.htm

<!DOCTYPE html>
<html>
<head>
</head>
<body>
    <h1>This is my written content.</h1>
</body>
</html>
但是,使用这样的临时引用:

tempDocument.open( "text/html" );
tempDocument.write( pageContent );
tempDocument.close();
工作正常。

可以提供一些见解。也许还可以提供一些见解。也可以
<!DOCTYPE html>
<html>
<head>
</head>
<body>
    <h1>This is my written content.</h1>
</body>
</html>
document.open( "text/html" );
document.write( pageContent );
document.close();
tempDocument.open( "text/html" );
tempDocument.write( pageContent );
tempDocument.close();