* Math对象
常用方法
方法 | 说明 | 示例 |
ceil() | 对数进行上舍入 | Math.ceil(25.5);返回26 Math.ceil(-25.5);返回-25 |
floor() | 对数进行下舍入 | Math.floor(25.5);返回25 Math.floor(-25.5);返回-26 |
round() | 把数四舍五入为最接近的数 | Math.round(25.5);返回26 Math.round(-25.5);返回-26 |
random() | 返回0~1之间的随机数 | Math.radom();例如:0.6273608814137365 |
实现返回的整数范围为2~99:var iNum = Math.floor(Math.random()*98+2);
*Date对象
语法:var 日期对象 = new Date(参数) 参数格式:MM DD,YYYY,hh:mm:ss
常用方法
方法 | 说明 |
getDate() | 返回 Date 对象的一个月中的每一天,其值介于1~31之间 |
getDay() | 返回 Date 对象的星期中的每一天,其值介于0~6之间 |
getHours() | 返回 Date 对象的小时数,其值介于0~23之间 |
getMinutes() | 返回 Date 对象的分钟数,其值介于0~59之间 |
getSeconds() | 返回 Date 对象的秒数,其值介于0~59之间 |
getMonth() | 返回 Date 对象的月份,其值介于0~11之间 |
getFullYear() | 返回 Date 对象的年份,其值为4位数 |
getTime() | 返回自某一时刻(1970年1月1日)以来的毫秒数 |
1、getDay():0--表示周日,1--表示周1,6--代表周6
2、getMonth(): 0 - 11,0代表1月份,11代表12月份
* 定时函数
语法:setTimeout("调用的函数",等待的毫秒数) selInterval("调用的函数",间隔的毫秒数)
* 清除函数
clearTimeout( setTimeOut()返回的ID值 ) clearInterval( setInterval()返回的ID值 )
* 小结
window对象实现弹出窗口、关闭当前窗口、弹出页面消息等效果
Date对象获得当前系统的日期、时间
定时函数:setTimeOut() 和 setInterval()
history和location对象实现浏览器中 “后退” 、 “前进” 和 “刷新”
document对象的方法:getElementById() getElementsByName() getElementsByTagName()