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

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

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

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

平常都不寫document.open() 與 document.close(),因為瀏覽器會在write之前先open一個文檔,再把write的內容輸出到原文檔里面。write結束后,默認是不會有close的,否則第二行document.write的時候就會覆蓋之前的write。

JavaScript技術document.open() 與 document.write()的區別,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 梅州市| 隆昌县| 荣成市| 宜兰市| 建昌县| 清徐县| 都江堰市| 清水河县| 广汉市| 哈尔滨市| 霸州市| 普兰县| 洞口县| 凯里市| 宁阳县| 西安市| 东宁县| 禹城市| 东明县| 鹤山市| 通城县| 仪陇县| 梁河县| 革吉县| 南城县| 二连浩特市| 萝北县| 长海县| 会宁县| 涿州市| 伊宁县| 美姑县| 河西区| 安庆市| 大港区| 阿合奇县| 禄丰县| 彰化县| 墨脱县| 六盘水市| 昌吉市|