这篇翻译不完整。请帮忙从英语翻译这篇文章 方法打开一个要写入的文档。



document.write("<html><p>remove me</p></html>");; 
// 文件是空的。



此外,当 document.write() 在页面加载后调用,但在W3C规范中没有定义时,会发生自动的调用。
document non-spec'ed parameters to

Do not confuse this method with allows you to overwrite the current document or append to it, while provides a way to open a new window, leaving the current document intact. Since window is the global object, just calling open(...) does the same as can close the opened document using document.close().

See Security check basics for more about principals.


Specification Status Comment
Document Object Model (DOM) Level 2 HTML Specification
Recommendation Initial definition


Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support (Yes) (Yes) (Yes) (Yes) (Yes) (Yes)
Feature Android Edge Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support ? (Yes) ? ? ? ?

Gecko-特定的 注意

Starting with Gecko 1.9, this method is subject to the same same-origin policy as other properties, and does not work if doing so would change the document's origin.

Starting with Gecko 1.9.2, uses the principal of the document whose URI it uses, instead of fetching the principal off the stack. As a result, you can no longer call document.write() into an untrusted document from chrome, even using wrappedJSObject.


 此页面的贡献者: xgqfrms-GitHub
 最后编辑者: xgqfrms-GitHub,