write and writeln
在JavaScript中可以使用Write()或者writeln()来输出文本.下面是例子:
<HTML>
<HEAD>
<TITLE> Welcome to my site</TITLE></HEAD>
<BODY>
<SCRIPT LANGUAGE="JAVASCRIPT">
<!--
document.write("Welcome to my site!");
// -->
</SCRIPT>
</BODY>
</HTML>
注意:文档对象write是小写,JavaScript对大小写是敏感的,区分大小写.write和writelen的区别是:write只是输出文本,write输出文本和一个换行符.
文档对象在JavaScript中是最重要的对象之一.下面是很简单的JavaScript代码:
document.write("Hi there.")
在代码中,document是对象,write是这个对象的方法.让我们看看下面看看文档对象还有别的什么方法.
lastModified
你通常可以得到最后的更新时间在你的网页上利用下面的代码:
<script language="JavaScript">
document.write("这个网页由XX建立,最后更新时间是:" + document.lastModified);
</script>
All you need to do here is use the lastModified property of the document. Notice that we used + to put together This page created by John N. Last update: and document.lastModified.
在这里你所做的就是利用文档对象的lastModified属性.注意我们用+来连接”这个网页由XX建立,最后更新时间是:” 和document.lastModified
bgColor and fgColor
让我们来试试bgColor 和 fgColor,用来设置背景色和前景色:
<script>
document.bgColor="black"
document.fgColor="#336699"
</script>

浙公网安备 33010602011771号