1、iframe src=/blog/*.html/iframe/noscript11. input type=button value=查看网页源代码 onclick=window.location = view-source:+ http:/www.williamlong.info12.删除时确认 a href=javascript:if(confirm(确实要删除吗?)location=boos.asp?&areyou=删除&page=1删除13. 取得控件的绝对位置 /Javascript Javascriptfunction getIE(e) var t=e.offsetTop;var
2、l=e.offsetLeft;while(e=e.offsetParent) alert(top=+t+/nleft=+l); /VBScript VBScriptfunction getIE() dim t,l,a,b set a=document.all.img1 t=document.all.img1.offsetTop l=document.all.img1.offsetLeft while a.tagName14. 光标是停在文本框文字的最后 javascriptfunction cc() var e = event.srcElement;var r =e.createTextRan
3、ge();r.moveStart(character,e.value.length);r.collapse(true);r.select();input type=text name=text1 value=123 onfocus=cc()15. 判断上一页的来源 document.referrer 16. 最小化、最大化、关闭窗口 object id=hh1 classid=clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11param name=Command value=Minimize/objectobject id=hh2 classid=Maximi
4、zeOBJECT id=hh3 classid=adb880a6-d8ff-11cf-9377-00aa003b7a11PARAM NAME= VALUE=Close/OBJECTinput type=button value=最小化 onclick=hh1.Click()input type=button value=最大化 onclick=hh2.Click()input type=button value=关闭 onclick=hh3.Click()本例适用于IE 17.屏蔽功能键Shift,Alt,Ctrl scriptfunction look() if(event.shiftKey
5、) 禁止按Shift键!); /可以换成ALTCTRL document.onkeydown=look;18. 网页不会被缓存 META HTTP-EQUIV=pragma CONTENT=no-cacheCache-Controlno-cache, must-revalidateexpiresWed, 26 Feb 1997 08:21:57 GMT或者20.spanlayer的区别?(division)用来定义大段的页面元素,会产生转行 用来定义同一行内的元素,跟的唯一区别是不产生转行 是ns的标记,ie不支持,相当于让横条没有:overflow-x:两个都去掉?更简单了 body scr
6、oll=no23.怎样去掉图片链接点击后,图片周围的虚线?# onFocus=this.blur()img src=/blog/logo.jpg border=024.电子邮件处理提交表单 form name=form1 method=post action=mailto:*.com enctype=text/plaininput type=submit/form25.在打开的子窗口刷新父窗口的代码里如何写?window.opener.location.reload() 26.如何设定打开页面的大小 body onload=top.resizeTo(300,200);打开页面的位置body b
7、ackground-image:url(/blog/logo.gif); background-repeat:no-repeat;background-position:center;background-attachment: fixed /STYLE28. 检查一段字符串是否全由数字组成 function checkNum(str)return str.match(/D/)=null alert(checkNum(1232142141) 123214214a129. 获得一个窗口的大小 document.body.clientWidth; document.body.clientHeigh
8、t 30. 怎么判断是否是字符 if (/x00-/xff/g.test(s) alert(含有汉字else alert(全是字符31.TEXTAREA自适应文字行数的多少 textarea rows=1 name=s1 cols=27 onpropertychange=this.style.posHeight=this.scrollHeight32. 日期减去天数等于第二个日期 script language=Javascriptfunction cc(dd,dadd) /可以加上错误处理 var a = new Date(dd) a = a.valueOf() a = a - dadd *
9、 24 * 60 * 60 * 1000 a = new Date(a) alert(a.getFullYear() + 年 + (a.getMonth() + 1) + 月 + a.getDate() + 日) cc(12/23/2002,2) 33. 选择了哪一个Radio HTMLvbscriptfunction checkme() for each ob in radio1 if ob.checked then window.alert ob.value next BODYINPUT name=radio1 type=radiostyle checkedStyle barcodeBar
10、code INPUT type=buttoncheck onclick=checkme()/BODY/HTML34.脚本永不出错 SCRIPT LANGUAGE=- Hide function killErrors() return true;window.onerror = killErrors;35.ENTER键可以让光标移到下一个输入框 input onkeydown=if(event.keyCode=13)event.keyCode=936. 检测某个网站的链接速度:把如下代码加入区域中:tim=1 setInterval(tim+,100) b=1 var autourl=new A
11、rray() autourl1=autourl2=autourl3=autourl4=autourl5=function butt() document.write(form name=autoffor(var i=1;i =input type=button value=GO onclick=window.open(this.form.url.value)brinput type=submit value=刷新butt() function auto(url) else b+ function run()for(var i=1;i+)document.write(img src=http:/
12、+autourl+/+Math.random()+ width=1 height=1 onerror=auto() run()37. 各种样式的光标 auto :标准光标 default :标准箭头 hand :手形光标 wait :等待光标 text :I形光标 vertical-text :水平I形光标 no-drop :不可拖动光标 not-allowed :无效光标 help :?帮助光标 all-scroll :三角方向标 move :移动标 crosshair :十字标 e-resize n-resize nw-resize w-resize s-resize se-resize
13、sw-resize 38.页面进入和退出的特效 进入页面meta http-equiv=Page-Enter content=revealTrans(duration=x, transition=y)推出页面解决问题:由于层与下拉框之间的优先级是:下拉框 层,因此在显示的时候,会因为优先级的次序而会出现如上问题。(如果几个元素都是层的话,我们可以通过层的 z-index 属性来设置)解决办法就是:给层中放一个优先级比下拉框更高的元素(iframe),从而解决此问题!具体解决代码如下:div id=menu style=position:absolute; visibility:hidden;
14、top:20px; left: width:100px; height:200px; background-color:#6699cc;tabletritem 1/tritem 2item 3item 4item 5document.getElementById(menu).style.visibility=visiblemenuselectoptionA form selection list/select输入框也可以做的很漂亮了 div align=centerinput type= name=haoyes外向数:input name=answer style=color: rgb(255
15、,0,0); border-left: medium none; 1px solid rgb(192,192,192)没回答的题数:name=unanswer id=unanswer总得分:name=score id=score结论:name=xgjg id=xgjginput onClick=processForm(this.form) style=FONT-FAMILY: 宋体; FONT-SIZE: 9pt type=button value=查看结果 name=resetSubmit重做注意:修改为max.Click()即为打开最大 化窗口,而如果改为min.Click()就变为窗口一打开就最小化 object id=minapplication/x-oleobject classid= maxadb880a6-d8f
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1