您的位置:首页 > 移动开发 > Objective-C

Codeproject--JavaScript For Beginners(2)write and writeln_Document object

2005-01-07 10:59 711 查看
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输出文本和一个换行符.

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属性.注意我们用+来连接”[/i]这个网页由[/i]XX[/i]建立[/i],[/i]最后更新时间是[/i]:” [/i]和document.lastModified

bgColor and fgColor

让我们来试试bgColor 和 fgColor,用来设置背景色和前景色:

<script>

document.bgColor="black"

document.fgColor="#336699"

</script>

 

 JavaScript For Beginners
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐