1.数组
声明创建:var 数组名 = new Array(数组大小);
例如:var name = new Array(“张三”,“李四”,“王五”);
属性:length,可以得到数组的长度
方法:
- join(将数组中的元素组合成字符串)
- reverse(颠倒数组元素的顺序)
- sort(对数组元素进行排序)
2.脚本对象
2.1.String
2.2Math
2.3.Date
3.系统函数
setTimeout(“调用的函数”,“定时的时间”),自动定时调用
4.浏览器对象
4.1window对象
4.2location对象
location.href = “目标url” 跳转至指定页面
4.3screen对象(只读)(可以得到当前屏幕的分辨率)
属性:width,height
4.4history
back()
forward()
go(-1)后退
5.js事件
6.动态显示时间
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>动态显示时间</title>
<style type="text/css">
#time {
border-top-width: 0px;
border-right-width: 0px;
border-bottom-width: 0px;
border-left-width: 0px;
}
</style>
<script type="text/javascript">
var dingshiqi = "";
function getNowDate(){
var now = new Date();
var time = now.getFullYear();
time += "-";
time += now.getMonth() + 1;
time += "-";
time += now.getDate() + " ";
time+=now.getHours()+":";
if(now.getMinutes()<10){
time+="0" ;
}
time+=now.getMinutes()+":";
if(now.getSeconds()<10){
time+="0" ;
}
time += now.getSeconds();
document.getElementById("time").value = time;
dingshiqi = setTimeout("getNowDate()",1000);
}
function stopTime(){
window.clearTimeout(dingshiqi);
}
</script>
</head>
<body "getNowDate()">
time:
<input type="text" name="time" id="time" />
<input type="button" name="pause" id="pause" value="pause" "getNowDate()"/>
<input type="button" name="continue" id="continue" value="continue" "stopTime()" />
</body>
</html>