js学习笔记2

Task 32

Calling Your JavaScript Code after the Page Has Loaded
页面加载完成后调用JavaScript Code

<head>
<script language=”JavaScript”>
<!--
function hello() {
window.alert(“Hello”);
}
// -->
</script>
</head>

<body onLoad=”hello();”>
The page’s content.
</body>

 

Task 43

Check If Java Is Enabled with JavaScript
检查页面是否可以运行Java

Sometimes it is useful to know whether or not Java is enabled and to use that
information in composing your pages. For instance, based on that informa-
tion, you could dynamically adjust the content of your page to include or not
include Java-based content.
Luckily, JavaScript provides a simple mechanism for determining this: the navi-
gator.javaEnabled method. This method returns true if Java is enabled in
the browser and false otherwise.

 

Task 44

Accessing the document Object
获取页面上的document对象

The document object is an extremely powerful and important object in
JavaScript that allows you to output data to the browser’s document stream,
as well as to access elements in the current document rendered in the browser.
Using this object, you can generate dynamic output in your document, and you
can manipulate the state of the document once rendered. The document object
provides a lot of information, methods, and access to objects reflecting the cur-
rent document, including the following:

a. Arrays containing anchors, applets, embedded objects, forms, layers,
links, and plug-ins from the current document.
b. Properties providing information about the current page, including
link colors, page background color, associated cookies, the domain of
the page, the modification date, the referring document, the title, and
the URL of the current document.
c. Methods to allow outputting text to the document stream, events to
handle events, and an event to return text currently selected in the
document.


Task 49

Controlling the Format of Date Output
控制日期输出方式

a. toGMTString: Returns the time as a string converted to Greenwich
Mean Time. The results look like this:
Thu, 17 Apr 2003 17:47:44 UTC
b. toLocaleString: Returns the time as a string using the date for-
matting conventions of the current locale. The results look like this
in Canada:
April 17, 2003 10:47:44 AM
c. toUTCString: Returns the time as a string converted to Universal
Time. The results look like this in North America:
Thu, 17 Apr 2003 17:47:44 UTC

相关函数:
getDate: Returns the current day of the month as a number
getDay : Returns the current day of the week as a number between 0(Sunday) and 6 (Saturday)
getFullYear: Returns the four-digit year
getHours: Returns the hour from the current time as a number between 0 and 23
getMinutes: Returns the minutes from the current time as a number between 0 and 59
getMonth: Returns the current month as a number between 0(January) and 11 (December)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值