当前位置:编程学习 > JS >>

JavaScript For Beginners(转载)

答案:

注:我对原文进行了编辑,对一些词汇标注颜色,方便阅读。本来准备翻译,但是觉得文章简单易懂,而且原文写得很好,所以就不献丑了。希望对JavaScript初学者能有所帮助。你可以跟着作者一起做那些示例代码,等读完文章的时候,你就可以掌握JavaScript的基本操作了,你会发现其实这一切很容易。

Contents
Embedding and including
write and writeln
Document object
Message box
Function
Event handler
Form
Link
Date
Window
Frame

Embedding and including

Let's first see a simple example:

< html >
< head >
< title > This is a JavaScript example </ title >
< script language ="JavaScript" >
<!--
document.write(
" Hello World! " );
// -->

</ script >
</ head >
< body > Hi, man! </ body >
</ html >

Usually, JavaScript code starts with the tag <Script language="JavaScript"> and ends with the tag </script>. The code placed between <head> and </head>. Sometimes, people embed the code in the <body> tags:

< html >
< head ></ head >
< body >
< script >
..
// The code embedded in the <body> tags.
</ script >
</ body >
</ html >

Why do we place JavaScript code inside comment fields <!-- and //--> ?
It's for ensuring that the Script is not displayed by old browsers that do not support JavaScript. This is optional, but considered good practice. The LANGUAGE attribute also is optional, but recommended. You may specify a particular version of JavaScript:

< script language ="JavaScript1.2" >

You can use another attribute SRC to include an external file containing JavaScript code:

如何用javascript判断录入的日期是否合法
下一个:对象的类型:本地对象(1)

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,