中文字幕一区二区人妻电影,亚洲av无码一区二区乱子伦as ,亚洲精品无码永久在线观看,亚洲成aⅴ人片久青草影院按摩,亚洲黑人巨大videos

HTML DOM open() 方法

Document 對(duì)象參考手冊(cè) Document 對(duì)象

定義和用法

open() 方法打開一個(gè)輸出流來(lái)收集 document.write()document.writeln() 方法輸出的內(nèi)容。

調(diào)用 open() 方法打開一個(gè)新文檔并且用 write() 方法設(shè)置文檔內(nèi)容后,必須記住用 document.close() 方法關(guān)閉文檔,并迫使其內(nèi)容顯示出來(lái)。

注意:如果目標(biāo)文件已經(jīng)存在,它將被清除。如果這個(gè)方法沒(méi)有參數(shù),會(huì)顯示一個(gè)新窗口(about:blank)。

語(yǔ)法

document.open(MIMEtype,replace)
參數(shù) 描述
MIMEtype 可選。規(guī)定正在寫的文檔的類型。默認(rèn)值是 "text/html"。
replace 可選。當(dāng)此參數(shù)設(shè)置后,可引起新文檔從父文檔繼承歷史條目。

瀏覽器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主要瀏覽器都支持 open() 方法


實(shí)例

實(shí)例

打開一個(gè)輸出流并添加文本,然后關(guān)閉輸出流:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>小白教程(json.cn)</title>
<script>
function createDoc(){
????var doc=document.open("text/html","replace");
????var txt="<!DOCTYPE html><html><body>學(xué)習(xí) HTML DOM 很有趣!</body></html>";
????doc.write(txt);
????doc.close();
}
</script>
</head>

<body>
<input type="button" value="新文檔" onclick="createDoc()">
</body>
</html>

運(yùn)行代碼 ?

實(shí)例 2

打開一個(gè)輸出流 (一個(gè)新窗口; about:blank),并添加文本,然后關(guān)閉輸出流:

<html>
<body>

<script>
var w=window.open();
w.document.open();
w.document.write("<h1>Hello World!</h1>");
w.document.close();
</script>

</body>
</html>

運(yùn)行代碼 ?

Document 對(duì)象參考手冊(cè) Document 對(duì)象其他擴(kuò)展