1、- function loopy() var sWord =; while(sWord!=login)sWord=prompt(请输入你的登陆密码); alert(登陆成功! loopy() /-/script5。拉动页面时背景图不动 style bodybackground-image:url(logo.gif); background-repeat:no-repeat;background-position:center /style6。让浏览器在保存页面时保存失败 NOSCRIPTiframe src=*.html/iframe/NOSCRIPT7。随机替换图片 script docum
2、ent.write(img src=img/+parseInt(Math.random()*(5) +.gifheight=40 width=50 图片文件名为0.gif 1.gif 2.gif 3.gif 4.gif 8。窗口定时关闭 先将如下代码网页文件的区:script language= function closeit() setTimeout(self.close(),10000) /毫秒 然后再在标内加入如:body onload=closeit()9。网页自动关闭 htmlheadobject id=closes type=application/x-oleobject cla
3、ssid=clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11param name=Command value=Close/object/headwindow.setTimeout(closes.Click(),10000) 这个窗口会在10秒过后自动关闭,而且不会出现提示. /body/html10。网页自动刷新 在head部记入 META HTTP-EQUIV=Refresh content=20 其中20为20秒后自动刷新,你可以更改为任意值。11。网页自动转页 CONTENT=时间(秒);URL=地址12。保持layer在最前面,而不被Iframe、Ob
4、ject所覆盖 在Layer中再插Iframe 或 Object 设z-Index值 div z-Index:2object xxx 前面 1 后面 div id=Layer2 style=position:absolute; top:40;width:400px; height:95px;z-index:2 height=100% width=100%iframe width=0 height=0/divLayer150;200px;115px;1iframe height=100% width=100%13。返回上一页 a href=javascript :history.back(1)返
5、回上一页关闭窗口16. oncontextmenu=window.event.returnValue=false 将彻底屏蔽鼠标右键 tdno 可用于Table 17. body onselectstart= 取消选取、防止复制 18.onpaste= 不准粘贴 19.oncopy=return false; oncut= 防止复制20. link rel=Shortcut Icon href=favicon.ico IE地址栏前换成自己的图标21. Bookmark 可以在收藏夹中显示出你的图标22. 24. 防止被人frameSCRIPT LANGUAGE=JAVASCRIPTif (to
6、p.location != self.location)top.location=self.location;25. 网页将不能被另存为noscriptiframe src=*.html/noscript26. 查看网页源代码input type=button value=查看网页源代码 onclick=window.location = view-source:+ 27.删除时确认if(confirm(确实要删除吗?)location=boos.asp? &areyou=删除&page=1删除28.屏蔽功能键Shift,Alt,Ctrl function look() if(event.sh
7、iftKey) alert(禁止按Shift键! /可以换成ALTCTRL document.onkeydown=look;29. 网页不会被缓存 pragmano-cacheCache-Controlno-cache, must-revalidateexpiresWed, 26 Feb 1997 08:21:57 GMT或者030.怎样让表单没有凹凸感?input type=text style=border:1 solid #000000或 31.不要滚动条?让竖条没有:overflow:scroll;让横条没有:overflow-x:两个都去掉?更简单了 body scroll=no32
8、.怎样去掉图片链接点击后,图片周围的虚线? onFocus=this.blur()logo.jpg border=033.电子邮件处理提交表单form name=form1 method=post action=mailt*.com enctype=text/plaininput type=submit/form34.在打开的子窗口刷新父窗口的代码里如何写?window.opener.location.reload()35.如何设定打开页面的大小 top.resizeTo(300,200);打开页面的位置body background-image: background-repeat:cent
9、er;background-attachment: fixed /STYLE37. 检查一段字符串是否全由数字组成 Javascriptfunction checkNum(str)return str.match(/D/)=null alert(checkNum(1232142141) 123214214a138. 获得一个窗口的大小 document.body.clientWidth; document.body.clientHeight39. 怎么判断是否是字符 if (/x00-/xff/g.test(s) alert(含有汉字else alert(全是字符40.TEXTAREA自适应文
10、字行数的多少 textarea rows=1 name=s1 cols=27 onpropertychange=this.style.posHeight=this.scrollHeight41. 日期减去天数等于第二个日期 script language=Javascriptfunction cc(dd,dadd) /可以加上错误处理 var a = new Date(dd) a = a.valueOf() a = a - dadd * 24 * 60 * 60 * 1000 a = new Date(a) alert(a.getFullYear() + 年 + (a.getMonth() +
11、 1) + 月 + a.getDate() + 日) cc(12/23/2002,2) 42. 选择了哪一个Radio HTMLvbscriptfunction checkme() for each ob in radio1 if ob.checked then window.alert ob.value next end function BODYINPUT name=radio1 type=radiostyle checkedStyle barcodeBarcode INPUT type=buttoncheck onclick=checkme()/BODY/HTML43.脚本永不出错 -
12、Hide function killErrors()return true; window.onerror = killErrors; / -44.ENTER键可以让光标移到下一个输入框 input onkeydown=if(event.keyCode=13)event.keyCode=945. 检测某个网站的链接速度:把如下代码加入for(var i=1;i =input type=button value=GOonclick=window.open(this.form.url.value)brinput type=submit value=刷新butt() function auto(ur
13、l) document.forms0url+b.value=url if(tim200) document.forms0txt+b.value=链接超时else 时间+tim/10+秒 b+ function run()for(var i=1;i+)document.write(img src=http:/+autourl+/+Math.random()+ width=1 height=1 nerror=auto(http:) run()1. 将彻底屏蔽鼠标右键 可用于Table2. 取消选取、防止复制3. 不准粘贴4. 防止复制5. 6. 7. 10. 网页将不能被另存为11. 删除13.
14、取得控件的绝对位置/javascriptfunction getIE(E)var t=e.offsetTop;var l=e.offsetLeft;while(e=e.offsetParent)t+=e.offsetTop;l+=e.offsetLeft;top=+t+/nleft=+l);/VBScriptVBScriptfunction getIE()dim t,l,a,bset a=document.all.img1t=document.all.img1.offsetTopl=document.all.img1.offsetLeftwhile a.tagName14. 光标是停在文本框文字的最后script lan