发布于 2016-12-10 05:13:44 | 56 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的Javascript教程,程序狗速度看过来!

JavaScript客户端脚本语言

Javascript 是一种由Netscape的LiveScript发展而来的原型化继承的基于对象的动态类型的区分大小写的客户端脚本语言,主要目的是为了解决服务器端语言,比如Perl,遗留的速度问题,为客户提供更流畅的浏览效果。



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。


最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务