您好,欢迎访问三七文档
当前位置:首页 > 金融/证券 > 金融资料 > 网页前端整理的笔试题目
经典的Web前端或者JavaScript面试笔试题一、不定项选择题(每题3分,共30分)1.声明一个对象,给它加上name属性和show方法显示其name值,以下代码中正确的是()A.varobj=[name:zhangsan,show:function(){alert(name);}];B.varobj={name:”zhangsan”,show:”alert(this.name)”};C.varobj={name:”zhangsan”,show:function(){alert(name);}};D.varobj={name:”zhangsan”,show:function(){alert(this.name);}};2.以下关于Array数组对象的说法不正确的是()A.对数组里数据的排序可以用sort函数,如果排序效果非预期,可以给sort函数加一个排序函数的参数B.reverse用于对数组数据的倒序排列C.向数组的最后位置加一个新元素,可以用pop方法最后添加push最后删除popD.unshift方法用于向数组删除第一个元素开头添加unshift最后删除shift3.要将页面的状态栏中显示“已经选中该文本框”,下列JavaScript语句正确的是()A.window.status=”已经选中该文本框”B.document.status=”已经选中该文本框”C.window.screen=”已经选中该文本框”D.document.screen=”已经选中该文本框”4.点击页面的按钮,使之打开一个新窗口,加载一个网页,以下JavaScript代码中可行的是()A.inputtype=”button”value=”new”onclick=”open(?new.html?,?_blank?)”/B.inputtype=”button”value=”new”onclick=”window.location=?new.html?;”/C.inputtype=”button”value=”new”onclick=”location.assign(?new.html?);”/D.formtarget=”_blank”action=”new.html”inputtype=”submit”value=”new”//form5.使用JavaScript向网页中输出hello/,以下代码中可行的是()A.scripttype=”text/javascript”document.write(hello/h1);/scriptB.scripttype=”text/javascript”document.write(“h1hello/h1”);/scriptC.scripttype=”text/javascript”h1hello/h1/scriptD.h1scripttype=”text/javascript”document.write(“hello”);/script/h16.分析下面的代码:htmlheadscripttype=”text/javascript”functionwriteIt(value){document.myfm.first_text.value=value;}/script/headbodybgcolor=”#ffffff”formname=”myfm”inputtype=”text”name=”first_text”inputtype=”text”name=”second_text”/form/body/html以下说法中正确的是()A.在页面的第二个文本框中输入内容后,当鼠标离开第二个文本框时,第一个文本框的内容不变B.在页面的第一个文本框中输入内容后,当鼠标离开第一个文本框时,将在第二个文本框中复制第一个文本框的内容C.在页面的第二个文本框中输入内容后,当鼠标离开第二个文本框时,将在第一个文本框中复制第二个文本框的内容D.在页面的第一个文本框中输入内容后,当鼠标离开第一个文本框时,第二个文本框的内容不变7.下面的JavaScript语句中,()实现检索当前页面中的表单元素中的所有文本框,并将它们全部清空A.for(vari=0;iform1.elements.length;i++){if(form1.elements.type==”text”)form1.elements.value=”;}B.for(vari=0;idocument.forms.length;i++){if(forms[0].elements.type==”text”)forms[0].elements.value=”;}C.if(document.form.elements.type==”text”)form.elements.value=”;D.for(vari=0;idocument.forms.length;i++){for(varj=0;jdocument.forms.elements.length;j++){if(document.forms.elements[j].type==”text”)document.forms.elements[j].value=”;}}8.在表单(form1)中有一个文本框元素(fname),用于输入电话号码,格式如:010-82668155,要求前3位是010,紧接一个“-”,后面是8位数字。要求在提交表单时,根据上述条件验证该文本框中输入内容的有效性,下列语句中,()能正确实现以上功能A.varstr=form1.fname.value;if(str.substr(0,4)!=”010-”||str.substr(4).length!=8||isNaN(parseFloat(str.substr(4))))isNaN是否是非数值,true是非数值alert(“无效的电话号码!”);B.varstr=form1.fname.value;if(str.substr(0,4)!=”010-”&&str.substr(4).length!=8&isNaN(parseFloat(str.substr(4))))alert(“无效的电话号码!”);C.varstr=form1.fname.value;if(str.substr(0,3)!=”010-”||str.substr(3).length!=8||isNaN(parseFloat(str.substr(3))))alert(“无效的电话号码!”);D.varstr=form1.fname.value;if(str.substr(0,4)!=”010-”&&str.substr(4).length!=8&!isNaN(parseFloat(str.substr(4))))alert(“无效的电话号码!”);9.关于正则表达式声明6位数字的邮编,以下代码正确的是()A.varreg=/\d6/;B.varreg=\d{6}\;C.varreg=/\d{6}/;D.varreg=newRegExp(“\d{6}”);缺少//10.关于JavaScript里的xml处理,以下说明正确的是()A.Xml是种可扩展标记语言,格式更规范,是作为未来html的替代B.Xml一般用于传输和存储数据,是对html的补充,两者的目的不同C.在JavaScript里解析和处理xml数据时,因为浏览器的不同,其做法也不同D.在IE浏览器里处理xml,首先需要创建ActiveXObject对象11.以下哪些是javascript的全局函数:()A.escapeB.parseFloatC.eval//此外还有unscapeparseIntisNaNisFiniteD.setTimeoutE.alert2、以下哪个单词不属于javascript保留字:(B)A.withB.parentC.classD.void10、关于IE的window对象表述正确的有:(ACD)A.window.opener属性本身就是指向window对象B.window.reload()方法可以用来刷新当前页面//应该是window.location.reload()方法C.window.location=”a.html”和window.location.href=”a.html”的作用都是把当前页面替换成a.html页面D.定义了全局变量g;可以用window.g的方式来存取该变量二、问答题1.列举浏览器对象模型里常用的至少4个对象,并列举window对象的常用方法至少5个(10分)对象:Windowdocumentlocationscreenhistorynavigator方法:Alert()confirm()prompt()open()close()2.简述列举文档对象模型里document的常用的查找访问节点的方法并做简单说明(10分)Document.getElementById根据元素id查找元素Document.getElementByName根据元素name查找元素Document.getElementsTagName根据指定的元素名查找元素三、程序题1、补充按钮事件的函数,确认用户是否退出当前页面,确认之后关闭窗口;(10分)htmlheadscripttype=”text/javascript”functioncloseWin(){//在此处添加代码if(confirm(“确定要退出吗?”)){window.close();}}/script/headbodyinputtype=”button”value=”关闭窗口”onclick=”closeWin()”//body/html2、写出简单描述html标签(不带属性的开始标签和结束标签)的正则表达式,并将以下字符串中的html标签去除掉(15分)varstr=“div这里是divp里面的段落/p/div”;//scripttype=”text/javascript”varstr=“div这里是divp里面的段落/p/div”;varreg=/\/?\w+\/?/gi;alert(str.repalce(reg,””));/script3、完成foo()函数的内容,要求能够弹出对话框提示当前选中的是第几个单选框。(10分)htmlheadmetahttp-equiv=”Content-Type”content=”text/html;charset=utf-8″//headbodyscripttype=”text/javascript”functionfoo(){//在此处添加代码varoradio=document.getElementsByName(“radioGroup”);for(vari=0;ioraio.length;i++){if(oradio[i].checked==”true”)alert(“你点击的是第”+(i+1)+”个单选框”);}/scriptbodyformname=”form1″onsubmit=”fool()”inputtype=”radio”name=”radioGroup”/inputtype=”radio”name=”radioGroup”/inputtype=”radio”name=”radioGroup”/inputtype=”radio”name=”radioGroup”/inputtype=”submit”//form/body/html4、完成函数showImg(),要求能够动态根据下拉列表的选项变化,更新图片的显示(15分)bodyscripttype=”text/javas
本文标题:网页前端整理的笔试题目
链接地址:https://www.777doc.com/doc-2073067 .html