|
看一個(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)系我們修改或刪除,多謝。