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
在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
相关文章推荐
- Codeproject—JavaScript For Beginners(3) Variables and Conditions_ Function
- Codeproject—JavaScript For Beginners(5) Form_ Window_ Frame
- Codeproject—JavaScript For Beginners(4) Event handler_Link_Date
- Creating and consuming MFC DLLs for Beginners(转自www.codeproject.com)
- Xcode code sense and cmd+click to symbol doesn't work for 1 of my projects
- Smart Rules a Tool for Building and Testing Business Rules(转载与CodeProject)
- Codeproject--JavaScript For Beginners(1) Embedding and including
- Code Organization in Large AngularJS and JavaScript Applications(waititng for translate)
- Signing for requires a development team. Select a development team in the project editor. Code
- No plugin found for prefix 'jetty' in the current project and in the plugin groups [org.apache.mave
- CodeProject - Inserting relational data using DataSet and DataAdapter(上)
- compressoer the javascript and Css code
- Source code for the BirdVis project
- VS Code - Debugger for Chrome调试JavaScript的两种方式
- guide you changing RDC and MAC protocols for a contiki project(如何在contiki工程中修改默认的rdc,mac协议))
- How JavaScript works: inside the V8 engine + 5 tips on how to write optimized code
- 错误整理:No plugin found for prefix 'jetty' in the current project and in the plugin groups
- Domain Object Layer Design and Sample Code for LiteMDA
- [jQuery] 25 Cool and Helpful jQuery Plugins/Tutorials For Your Next Project
- PhoneGap: open source development framework for building cross-platform mobile apps, Build apps in HTML and JavaScript