document.open() 与 document.write()的区别
下面这个document.open() 与 document.write()的区别教程由图老师小编精心推荐选出,过程简单易学超容易上手,喜欢就要赶紧get起来哦!
看一个例子:
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。


