色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

document.open() 與 document.write()的區(qū)別

document.open()  打開一個(gè)新的空白文檔,在IE下,open有兩個(gè)默認(rèn)參數(shù),相當(dāng)于document.open("text/html",'""),第二個(gè)參數(shù)只有一個(gè)值可選:replace,如果啟用了該值,則新建的文檔會覆蓋當(dāng)前頁面的文檔(相當(dāng)于清空了原文檔里的所有元素,且不能后退即,瀏覽器的后退按鈕不可用);
看一個(gè)例子:

<SCRIPT LANGUAGE="JavaScript">
<!--
function test(){
 document.open("text/html","replace");
 document.writeln(Math.random());
 document.write("<input type='button' value='back(第二個(gè)按鈕)' onclick='history.back()'>")
 document.close();
 document.open("text/html","");
 document.writeln(Math.random());
 document.write("<input type='button' value='back(第三個(gè)按鈕)' onclick='history.back()'>")
 document.close();
 document.open("text/html","");
 document.writeln(Math.random());
 document.write("<input type='button' value='back(第四個(gè)按鈕)' onclick='history.back()'>")
 document.close();
}
//-->
</SCRIPT>
<input type="button" value="第一個(gè)按鈕" onclick="test()">

平常都不寫document.open() 與 document.close(),因?yàn)闉g覽器會在write之前先open一個(gè)文檔,再把write的內(nèi)容輸出到原文檔里面。write結(jié)束后,默認(rèn)是不會有close的,否則第二行document.write的時(shí)候就會覆蓋之前的write。

JavaScript技術(shù)document.open() 與 document.write()的區(qū)別,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 那曲县| 鲜城| 巴南区| 南木林县| 探索| 旬阳县| 海门市| 咸宁市| 抚宁县| 甘孜县| 台湾省| 绥德县| 灌阳县| 分宜县| 南华县| 漳平市| 从化市| 峨山| 上杭县| 镇原县| 湄潭县| 大埔区| 龙口市| 苍南县| 美姑县| 化州市| 南涧| 凤城市| 汪清县| 长白| 永城市| 常宁市| 射洪县| 阿鲁科尔沁旗| 哈密市| 翁源县| 渭源县| 德兴市| 鄢陵县| 晋城| 东港市|