JavaScript(2)———常用对象

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>

		
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值