语法:
oNewDoc = document . open ( sURL , sName )
参数:
sUrl : 必选项。字符串(String)。当打开一个新的文档( document )时,此参数用于指定文档( document )的多用途网际邮件扩充协议(MIME - Multipurpose Internet Mail Extensions)。默认值为 text/html 。目前此方法仅支持此种 MIME 类型。
sName : 可选项。字符串(String)。当打开一个新的文档( document )时,指定此参数值为 replace ,则新文档会覆盖掉历史列表里的当前文档。忽略此参数则新文档被简单的添加到历史列表的最后。 replace : 新文档覆盖历史列表里的当前文档。
返回值:
oNewDoc : 对象(Element)。返回对新的 document 对象的引用。
说明:
打开新文档为 write 和 writeln 的输出做准备。
当文档内的对象上的事件( event )激发的函数调用 open 方法时, window 对象的 open 方法被使用。而当文档内的对象上的事件( event )直接使用 open 方法时, document 对象的 open 方法被使用。
<script>
function rdl_doAdd(){
var oSelect=document.all("idSelect");
document.open("text/html");
document.writeln("新写入的文本\n");
document.close();
}
</script>
<table height=40 width=90%><tr>
<td nowrap>
<input type=button value=" 写入 " onclick="rdl_doAdd();"></td>
</tr></table>
