资源描述
复习题
一、选取题
1、写“Hello World”对的javascript语法是? (A)
A. document.write("Hello World") B. "Hello World"
C. response.write("Hello World") D. ("Hello World")
2、JS特性不涉及( D )
A.解释性 B.用于客户端 C.基于对象 D.面向对象
3、下列JS判断语句中( )是对的 (A)
A.if(i==0) B.if(i=0) C.if i==0 then D.if i=0 then
4、下列JavaScript循环语句中( )是对的 ( D )
A.if(i<10;i++) B.for(i=0;i<10)
C.for i=1 to 10 D.for(i=0;i<=10;i++)
5、下列哪一种表达式将返回假 ( B )
A.!(3<=1) B.(4>=4)&&(5<=2)
C.(“a”==”a”)&&(“c”!=”d”) D.(2<3)||(3<2)
6、下列选项中,( )不是网页中事件 (D)
A.onclick B.onmouseover C.onsubmit D.onpressbutton
7、有语句“var x=0;while(____) x+=2;”,要使while循环体执行10次,空白处循环鉴定式应写为: ( C )
A.x<10 B. x<=10 C.x<20 D.x<=20
8、JS语句 ( B )
var a1=10;
var a2=20;
alert(“a1+a2=”+a1+a2)
将显示( )成果
A.a1+a2=30 B.a1+a2=1020 C.a1+a2=a1+a2
9、将字串s中所有字母变为小写字母办法是 ( B)
A.s.toSmallCase() B.s.toLowerCase()
C.s.toUpperCase() D.s.toUpperChars()
10、如下( )表达式产生一种0~7之间(含0,7)随机整数. ( C )
A.Math.floor(Math.random()*6)
B.Math.floor(Math.random()*7)
C.Math. floor(Math.random()*8)
D.Math.ceil(Math.random()*8)
11、产生当前日期办法是 ( C )
A.Now(); B.Date() C.new Date() D.new Now()
12、如果想在网页显示后,动态地变化网页标题 ( C )
A.是不也许 B.通过document.write(“新标题内容”)
C. 通过document.title=(“新标题内容”)
D. 通过document.changeTitle(“新标题内容”)
13、某网页中有一种窗体对象,其名称是mainForm,该窗体对象第一种元素是按钮,其名称是myButton,表述该按钮对象办法是 ( B )
A.document.forms.myButton B.document.mainForm.myButton
C.document.forms[0].element[0] D.以上都可以
14、HTML文档树状构造中,()标签为文档根节点,位于构造中最顶层。 ( A )
A.<HTML>B.<HEAD>C.<BODY>D.<TITLE>
15、在HTML页面中,CSS样式属性名为background-image相应style对象属性名是(B)
A.background B.backgroungImage C.image D.background
16、在使用Javascript实现省市级联菜单功能时,在添加都市列表前清空本来下拉选项代码是(C)
A.document.myform.selCity.options.clear()
B. document.myform.selCity.options.deleteAll()
C. document.myform.selCity.options.length=0
D. document.myform.selCity.options.size=0
17、HMTL表单首要标记是<form>,<form>标记参数method表达表单发送办法,也许为get或post,下列关于get和post描述对的是(D)
A.post办法传递数据对客户端是不可见
B.get祈求信息以查询字符串形式发送,查询字符串长度没有大小限制
C.post办法对发送数据数量限制在255个字符之内
D.get办法传递数据对客户端是不可见
18、在DOM对象模型中,下列选项中()对象位于DOM对象模型第二层。(选取二项) (AB)
A.history B.document C.button D.text
19、在HTML文档对象模型中,history对象()用于加载历史列表中下一种URL页面。
( C )
A.next() B.back() C.forward() D.go(-1)
20、在Javascript中要变化页面文档背景色,需要修改document对象()属性。 ( C )
A.BackColor B.BackgroundColor C.BgColor D.Background
21、在HTML页面中,不能与onChange事件解决程序有关联表单元素有(D)
A.文本框 B.复选框 C.列表框 D.按钮
22、在HTML页面上编写Javascript代码时,应编写在()标签中间。 (B)
A.<javascript>和</javascript> B.<script>和</script> C. <head>和</head> D. <body>和</body>
23、在Javascript浏览器对象模型中,window对象()属性用来指定浏览器状态栏中显示暂时消息。 (A)
A.status B.screen C.history D.document
24、编写Javascript函数实现网页背景色选取器,下列选项中对的是(B)
A.function change(color){
window.bgColor=color;
}
B. function change(color){
document.bgColor=color;
}
C. function change(color){
body.bgColor=color;
}
D. function change(color){
form.bgColor=color;
}
25、在Javascript中,可以使用Date对象()办法返回一种月中每一天。 (A)
A.getDate B.getYear C.getMonth D.getTime
26、在Javascript中,对于浏览器对象层次关系理解对的是()(选取二项) (AD)
A.window对象是所有页面内容根对象
B.document对象包括location对象和history对象
C.location对象包括history
D.document对象包括form对象
27、下列选项中关于浏览器对象说法错误是( C )
A.history对象记录了顾客在一种浏览器中已经访问过URLs
B.location对象相称于IE浏览器中地址栏,包括关于当前URL地址信息
C.location对象是history对象父对象
D.location对象是window对象子对象
28、在HTML页面中包括一种按钮控件mybutton,如果要实现点击该按钮时调用已定义Javascript函数compute,要编写HTML代码是(D)
A.<input name=”mybutton” type=”button” onBlur=”compute()”value=”计算”>
B.<input name=”mybutton” type=”button” onFocus=”compute()”value=”计算”>
C.<input name=”mybutton” type=”button” onClick=”function compute()”value=”计算”>
D.<input name=”mybutton” type=”button” onClick=”compute()”value=”计算”>
29、分析下面Javascript代码段,输出成果是(C)
var mystring=”I am a student”;
var a=mystring.substring(9,13);
document.write(a);
A.stud B.tuden C.uden D.udent
30、Javascript中制作图片代替按钮提交效果需要手动提交办法submit(),如下调用对的是(C)
A.submit();B.myform.submit() C.document.myform.submit() D.window.myform.submit();
31、在HTML页面中包括如下所示代码,则编写Javascript函数判断与否按下键盘上回车键对的编码是(C)
<input name=”password” type=”text” onkeydown=”myKeyDown()”>
A. function myKeyDown(){
if (window.keyCode==13)
alert(“你按下了回车键”);
B. function myKeyDown(){
if (document.keyCode==13)
alert(“你按下了回车键”);
C. function myKeyDown(){
if (event.keyCode==13)
alert(“你按下了回车键”);
D. function myKeyDown(){
if (keyCode==13)
alert(“你按下了回车键”);
32、如果在HTML页面中包括如下图片标签,则选项中()语句可以实现隐藏该图片功能。 (D)
<img id=”pic” src=”Sunset.jpg” width=”400” height=”300”>
A.document.getElementById(“pic”).style.display=”visible”;
B.document.getElementById(“pic”).style.display=”disvisible”;
C.document.getElementById(“pic”).style.display=”block”;
D.document.getElementById(“pic”).style.display=”none”;
33、如果在HTML页面中包括如下图片标签,则在下划线处添加()代码可以实现隐藏该图片功能。 ( D )
<img id=”pic” src=”Sunset.jpg” width=”400” height=”300” ____________ >
A. style=”display:visible”;
B. style=”display:disvisible”;
C. style=”display:block”;
D. style=”display:none”;
34、下列选项中,()段HTML代码所示“返回”链接可以正的确现IE工具栏中“后退”按钮功能。(选取二项) (AD)
A. <a href=”javascript:history.go(-1)”>返回</a>
B. <a href=”javascript:location.back()”>返回</a>
C. <a href=”javascript:location go(-1)”>返回</a>
D. <a href=”javascript:history.back()”>返回</a>
35、在HTML文档中包括如下超链接,要实现当鼠标移入该链接时,超链接文本大小变为30px,选项中编码对的是(C)
A.<a href=”#” onmouseover=”this.style.fontsize=30px”>注册</a>
B.<a href=”#” onmouseout=”this.style.fontsize=30px”>注册</a>
C.<a href=”#” onmouseover=”this.style.font-size=30px”>注册</a>
D.<a href=”#” onmouseout=”this.style.font-size=30px”>注册</a>
36、在HTML页面上,当按下键盘上任意一种键时都会触发Javascript()事件。
( D )
A.onFocus B.onBlur C.onSubmit D.onKeyDown
37、在HTML页面中,定义了如下所示Javascript函数,则对的调用该函数HTML代码是(选取二项) (AB)
function compute(op){
alert(op);
}
A.<input name=”a” type=”button” onclick=”compute(this.value)” value=”+”>
B.<input name=”b” type=”button” onclick=”compute(‘-‘)” value=”-”>
C.<input name=”c” type=”button” onclick=”compute(“*”)” value=”*”>
D.<input name=”d” type=”button” onclick=”compute(/ )” value=”/”>
38、在HTML页面上包括如下创立层语句,那么编写Javascript语句实现显示该层语句错误是(D)
<html>
<body>
<div id=”imageLayer” style=”display:none;”>
<img src=”images/Sunset.jpg” width=”200” height=”100”></div>
</body>
<html>
A. document.getElementByTagName(“div”)[0].style.display=”block”
B.document.getElementById(“imageLayer”).style.display=”block”;
C.document.getElementByName(“imageLayer”)[0].style.display=”block”;
D.document.getElementByName(“imageLayer”).get(0).style.display=”block”;
39、分析下面Javascript代码段,输出成果是(C)
var s1=parseInt(“101中学”);
document.write(s1);
A. NaN B.101中学 C.101 D.浮现脚本错误
40、在HTML中,点击图片”previous.gif”上超级链接后页面将加载历史列表中上一种URL页面。代码如下所示,应在下划线处填入(A)
<a href=_________><img src=”previous.gif” width=”67” height=”21”></a>
A.”javascript:history.go(-1)”;B. “history.go(1)” C. “history.go(-1)” D. “javascript:history.go(1)”
41、在HTML页面上包括如下所示层对象,则javascript语句document.getElementById(“info”).innerHTML值是(A)
<div id=”info” style=”display:block”><p>请填写</p></div>
A.请填写 B.<p>请填写</p> C.id=”info” style=”display:block”
D.<div id=”info” style=”display:block”><p>请填写</p>
42、如下哪条语句会产生运营错误(A)
A.varobj = ( ); B.varobj = [ ]; C.varobj = { }; D.var obj =/ /;
二、阅读程序写成果
1、function replaceStr(inStr,oldStr,newStr){
var rep = inStr;
while (rep.indexOf(oldStr) > -1) {
rep = rep.replace(oldStr,newStr);
}
return rep;
}
alert(replaceStr("how do you do","do","are"));
答:弹出警示对话框,显示how are you are。
2、<script>
var x,y=null;
alert(x) ;
alert(y) ;
alert(x=y);
alert(x==y);
</script>
答:依次弹出四个警示对话框,分别显示undefined、null、null、true。
3、</html>
x=”a”;
y=”b”;
z=false;
function testOne(){
var x=”c”;
var y=”d”;
z=true;
alert(x);
alert(y);
alert(z);
}
function testTwo(){
alert(x);
alert(y);
alert(z);
}
testOne();
testTwo();
答:依次弹出六个警示对话框,分别显示c、d、true、a、b、true。
4、当单击button按钮时,浮现什么成果。
<html>
<head>
<title>Untitled Document</title>
<script language=JavaScript>
function add(){
var first=document.myForm.first.value ;
var second=parseInt(document.myForm.second.value);
var third= parseInt(document.myForm.third.value);
alert(first+second+third);
}
</script>
</head>
<body>
<form name="myForm">
<input type=text name="first" value="40">
<input type=text name="second" value="30">
<input type=text name="third" value="70">
<input type=button value="add" onclick=add()>
</form>
</body>
答:弹出警示对话框,显示403070。
三、编写程序
1、实当前标题栏和状态栏上动态显示当前时间效果。
<html>
<head>
<title>新建网页 1</title>
</head>
<body onload="showTime()">
<script>
function showTime(){
now=new Date();
display=now.toLocaleString();
document.title=display;
status=display;
setTimeout("showTime()",1000)
}
</script>
</body>
</html>
2、互换图像。
<a onmouseover="document.p1.src='images/IMG02.JPG'" onmouseout="document.p1.src='images/IMG01.JPG'">
<img border="0" src="images/IMG01.JPG" width="200" height="150" name="p1">
</a>
3、变化下拉列表框选项时能显示当前选项文本和值。
<form name="a">
<select name="a" size="1" onchange="_sel(this)">
<option value="a">1</option>
<option value="b">2</option>
<option value="c">3</option>
</select>
</form>
<script>
function _sel(obj){
alert("显示文本:" + obj.options[obj.selectedIndex].text);
alert("值:" + obj.options[obj.selectedIndex].value);
}
</script>
4、规定可以弹出对话框提示当前选中是第几种单选框。
<html>
<body>
<script>
Function foo(){
var rg = document.getElementsByName("radioGroup");
for(var i= 0;i<rg.length;i++)
{
if(rg[i].checked)
{
alert("你选取了第" + (i+1) + "个单选框");
}
}
return false;
}
</script>
<body>
<form name="form1" onsubmit="return foo();">
<input type="radio" name="radioGroup"/>
<input type="radio" name="radioGroup"/>
<input type="radio" name="radioGroup"/>
<input type="radio" name="radioGroup"/>
<input type="radio" name="radioGroup"/>
<input type="radio" name="radioGroup"/>
<input type="submit"/>
</form>
</body>
</html>
5、变化下拉列表框显示图片,并显示在文本框中。
<html>
<head>
<title>图像切换</title>
<script>
function LoadImg(f){
document.img1.src=document.form1.D1.options[document.form1.D1.selectedIndex].value;
document.form1.T1.value=document.form1.D1.options[document.form1.D1.selectedIndex].value;
}
</script>
</head>
<body>
<form name="form1" >
<p><input type="text" name="T1" size="20">
<select size="1" name="D1" onchange="LoadImg(this.form)">
<option selected value="images\img01.jpg">图片一</option>
<option value="images\img02.jpg">图片二</option>
<option value="images\img03.jpg">图片三</option>
</select></p>
<img src="images\Img01.jpg" name="img1" width=250 height=200>
</form>
</body>
</html>
6、在下面HTML文档中,编写函数test() ,实现如下功能:
(1)当多行文本框中字符数超过20个,截取至20个
(2)在id为numbertd中显示文本框字符个数
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>留言</title>
<script>
function test(){
var content = document.getElementById("feedBack").value;
if(content.length>20){
content = content.substr(0,20);
}
document.getElementById("feedBack").value=content;
document.getElementById("number").innerHTML=content.length;
}
</script>
</head>
<body>
<table>
<tr>
<td>
留言
</td>
<td id="number">
0
</td>
</tr>
<tr>
<td colspan=2>
<textarea id="feedBack" onkeyup="test()" rows=6></textarea>
</td>
</tr>
</table>
</body>
</html>
展开阅读全文