知名网站建设定制第一章链接:
知名网站建设定制第二章链接:
知名网站建设定制第三章链接:
知名网站建设定制第四章链接:
第五章链接:
第六章链接:
第七章链接:
注:使用的是人民邮电出版社出版的《JavaScript+jQuery 交互式 Web 前端开发》书籍。
一、填空题
1、 在BOM中,所有对象的父对象是______。
2、页面中所有内容加载完之后触发的事件是______。
3、history对象的______属性可获取历史列表中的URL数量。
4、 ______事件是在DOM结构加载完触发的 。
二、判断题
1、全局变量可以通过window对象进行访问。( )
2、修改location对象的href属性可获取或设置URL。( )
3、使用clearTimeout()和clearInterval()可以。( )
4、使用history对象的 go()方法可以实现页面前进或后退。( )
三、选择题
1、下列选项中,不是window对象的属性的是( )。
A. pageX B. location C. history D. navigator
2、下面关于BOM对象的描述,错误的是( )。
A. go(-1)与back()皆表示向历史列表后退一步
B.通过confirm()实现的“确认”对话框,单击“确认”时返回true
C. go(0)表示刷新当前网页
D.以上选项都不正确
3、下列描述错误的是( )。
A. onload和DOMContentLoaded都是页面加载事件,没有区别
B. DOMContentLoaded有
C. 定义在全局作用域中的变量是window对象的属性
D. window对象的方法在调用时可以省略不写window
四、编程题
编写程序,实现电子时钟自动走动的效果,并提供一个按钮控制电子时钟是否停止走动。
参考答案:
一、填空题
1、window
2、window.onload
3、length
4、document.DOMContentLoaded
二、判断题
1、对 2、对 3、对 4、对
三、选择题
1、A 2、D 3、A
四、编程题
编写功能代码,具体代码如下:
<a id = "time"></a> <button onclick = "clearInterval(time1)">停止</button> <script type="text/javascript"> var time1 = window.setInterval('timeShow()', 1000); timeShow() function timeShow() { var today = new Date(); //获得系统当前时间 var intYears = today.getFullYear(); //获得年 intMonths = today.getMonth() + 1; //获得月份+1 intDates = today.getDate(); //获得天数 intHours = today.getHours(); //获得小时 intMinutes = today.getMinutes(); //获得分钟 intSeconds = today.getSeconds(); //获得秒 intWeeks = today.getDay(); //获得星期 // 修改格式为 *年*月*日 years = intYears + '年'; // 如果月份小于10,在月份前面加0 intMonths < 10 ? months = '0' + intMonths + '月' : months = intMonths + '月'; // 如果日份小于10,在日前面加0 intDates < 10 ? dates = '0' + intDates + '日' : dates = intDates + '日'; // 修改星期格式 var week = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'] weeks = week[intWeeks] + ' '; // 修改小时格式 if (intHours == 0) { hours = '00:'; } else if (intHours < 10) { hours = '0' + intHours + ':'; } else { hours = intHours + ":"; } // 修改分钟格式 if (intMinutes == 0) { minutes = '00'; } else if (intMinutes < 10) { minutes = '0' + intMinutes; } else { minutes = intMinutes+ ":"; } // 修改秒数格式 if (intSeconds == 0) { seconds = '00'; } else if (intSeconds < 10) { seconds = '0' + intSeconds; } else { seconds = intSeconds; } var timeString = years + months + dates + weeks + hours + minutes+seconds document.getElementById('time').innerHTML = timeString; } </script>