Program,Life,Society.....

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

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对大小写是敏感的,区分大小写.writewritelen的区别是:write只是输出文本,write输出文本和一个换行符.


Document object

文档对象在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>

 

 JavaScript For Beginners

posted on 2005-01-07 10:59  vuejs3  阅读(740)  评论(0)    收藏  举报