|
  
|
1#
发表于 2005-12-22 02:15
| 只看该作者
40个实用经典的网页特效代码
<STRONG><BR><BR></STRONG><SPAN style="FONT-SIZE: 12px">1. oncontextmenu="window.event.returnvalue=false" 将彻底屏蔽鼠标右键 <BR><table border oncontextmenu=return(false)><td>no</table> 可用于table <BR><BR>2. <body onselectstart="return false"> 取消选取、防止复制 <BR><BR>3. onpaste="return false" 不准粘贴 <BR><BR>4. oncopy="return false;" oncut="return false;" 防止复制 <BR><BR>5. <link rel="shortcut icon" href="favicon.ico"> ie地址栏前换成自己的图标 <BR><BR>6. <link rel="bookmark" href="favicon.ico"> 可以在收藏夹中显示出你的图标 <BR><BR>7. <input style="ime-mode:disabled"> 关闭输入法 <BR><BR>8. 永远都会带着框架 <BR><script language="javascript"><!-- <BR>if (window == top)top.location.href = "frames.htm"; //frames.htm为框架网页 <BR>// --></script> <BR><BR>9. 防止被人frame <BR><script language=javascript><!-- <BR>if (top.location != self.location)top.location=self.location; <BR>// --></script> <BR><BR>10. 网页将不能被另存为 <BR><noscript><iframe src=*.html></iframe></noscript> <BR><BR>11. <input type=button value=查看网页源代码 <BR>onclick="window.location = 'view-source:'+ 'http://www.51js.com/&#39;"> <BR><BR>12.删除时确认 <BR><a href='javascript:if(confirm("确实要删除吗?"))location="boos.asp?&areyou=删除&page=1"'>删 <BR><BR>除</a> <BR><BR>13. 取得控件的绝对位置 <BR>//javascript <BR><script language="javascript"> <BR>function getie(e){ <BR>var t=e.offsettop; <BR>var l=e.offsetleft; <BR>while(e=e.offsetparent){ <BR>t+=e.offsettop; <BR>l+=e.offsetleft; <BR>} <BR>alert("top="+t+"/nleft="+l); <BR>} <BR></script> <BR><BR>//vbscript <BR><script language="vbscript"><!-- <BR>function getie() <BR>dim t,l,a,b <BR>set a=document.all.img1 <BR>t=document.all.img1.offsettop <BR>l=document.all.img1.offsetleft <BR>while a.tagname<>"body" <BR>set a = a.offsetparent <BR>t=t+a.offsettop <BR>l=l+a.offsetleft <BR>wend <BR>msgbox "top="&t&chr(13)&"left="&l,64,"得到控件的位置" <BR>end function <BR>--></script> <BR><BR>14. 光标是停在文本框文字的最后 <BR><script language="javascript"> <BR>function cc() <BR>{ <BR>var e = event.srcelement; <BR>var r =e.createtextrange(); <BR>r.movestart('character',e.value.length); <BR>r.collapse(true); <BR>r.select(); <BR>} <BR></script> <BR><input type=text name=text1 value="123" onfocus="cc()"> <BR><BR>15. 判断上一页的来源 <BR>javascript: <BR>document.referrer <BR><BR>16. 最小化、最大化、关闭窗口 <BR><object id=hh1 classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"> <BR><param name="command" value="minimize"></object> <BR><object id=hh2 classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"> <BR><param name="command" value="maximize"></object> <BR><object id=hh3 classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"> <BR><param name="command" value="close"></object> <BR><BR><input type=button value=最小化 onclick=hh1.click()> <BR><input type=button value=最大化 onclick=hh2.click()> <BR><input type=button value=关闭 onclick=hh3.click()> <BR>本例适用于ie <BR><BR>17.屏蔽功能键shift,alt,ctrl <BR><script> <BR>function look(){ <BR>if(event.shiftkey) <BR>alert("禁止按shift键!"); //可以换成alt ctrl <BR>} <BR>document.onkeydown=look; <BR></script> <BR><BR>18. 网页不会被缓存 <BR><meta http-equiv="pragma" content="no-cache"> <BR><meta http-equiv="cache-control" content="no-cache, must-revalidate"> <BR><meta http-equiv="expires" content="wed, 26 feb 1997 08:21:57 gmt"> <BR>或者<meta http-equiv="expires" content="0"> <BR><BR>19.怎样让表单没有凹凸感? <BR><input type=text style="border:1 solid #000000"> <BR>或 <BR><input type=text style="border-left:none; border-right:none; border-top:none; border-bottom: <BR><BR>1 solid #000000"></textarea> <BR><BR>20.<div><span>&<layer>的区别? <BR><div>(division)用来定义大段的页面元素,会产生转行 <BR><span>用来定义同一行内的元素,跟<div>的唯一区别是不产生转行 <BR><layer>是ns的标记,ie不支持,相当于<div> <BR><BR><BR>21.让弹出窗口总是在最上面: <BR><body onblur="this.focus();"> <BR><BR>22.不要滚动条? <BR>让竖条没有: <BR><body style='overflow:scroll;overflow-y:hidden'> <BR></body> <BR>让横条没有: <BR><body style='overflow:scroll;overflow-x:hidden'> <BR></body> <BR>两个都去掉?更简单了 <BR><body scroll="no"> <BR></body> <BR><BR>23.怎样去掉图片链接点击后,图片周围的虚线? <BR><a href="#" onfocus="this.blur()"><img src="logo.jpg" border=0></a> <BR><BR>24.电子邮件处理提交表单 <BR><form name="form1" method="post" action="mailto:****@***.com" enctype="text/plain"> <BR><input type=submit> <BR></form> <BR><BR>25.在打开的子窗口刷新父窗口的代码里如何写? <BR>window.opener.location.reload() <BR><BR>26.如何设定打开页面的大小 <BR><body onload="top.resizeto(300,200);"> <BR>打开页面的位置<body onload="top.moveby(300,200);"> <BR><BR>27.在页面中如何加入不是满铺的背景图片,拉动页面时背景图不动 <BR><style> <BR>body <BR>{background-image:url(logo.gif); background-repeat:no-repeat; <BR><BR>background-position:center;background-attachment: fixed} <BR></style> <BR><BR>28. 检查一段字符串是否全由数字组成 <BR><script language="javascript"><!-- <BR>function checknum(str){return str.match(//d/)==null} <BR>alert(checknum("1232142141")) <BR>alert(checknum("123214214a1")) <BR>// --></script> <BR><BR>29. 获得一个窗口的大小 <BR>document.body.clientwidth; document.body.clientheight <BR><BR>30. 怎么判断是否是字符 <BR>if (/[^/x00-/xff]/g.test(s)) alert("含有汉字"); <BR>else alert("全是字符"); <BR><BR>31.textarea自适应文字行数的多少 <BR><textarea rows=1 name=s1 cols=27 onpropertychange="this.style.posheight=this.scrollheight"> <BR></textarea> <BR><BR>32. 日期减去天数等于第二个日期 <BR><script language=javascript> <BR>function cc(dd,dadd) <BR>{ <BR>//可以加上错误处理 <BR>var a = new date(dd) <BR>a = a.valueof() <BR>a = a - dadd * 24 * 60 * 60 * 1000 <BR>a = new date(a) <BR>alert(a.getfullyear() + "年" + (a.getmonth() + 1) + "月" + a.getdate() + "日") <BR>} <BR>cc("12/23/2002",2) <BR></script> <BR><BR>33. 选择了哪一个radio <BR><html><script language="vbscript"> <BR>function checkme() <BR>for each ob in radio1 <BR>if ob.checked then window.alert ob.value <BR>next <BR>end function <BR></script><body> <BR><input name="radio1" type="radio" value="style" checked>style <BR><input name="radio1" type="radio" value="barcode">barcode <BR><input type="button" value="check" onclick="checkme()"> <BR></body></html> <BR><BR>34.脚本永不出错 <BR><script language="javascript"> <BR><!-- hide <BR>function killerrors() { <BR>return true; <BR>} <BR>window.onerror = killerrors; <BR>// --> <BR></script> <BR><BR>35.enter键可以让光标移到下一个输入框 <BR><input onkeydown="if(event.keycode==13)event.keycode=9"> <BR><BR>36. 检测某个网站的链接速度: <BR>把如下代码加入<body>区域中: <BR><script language=javascript> <BR>tim=1 <BR>setinterval("tim++",100) <BR>b=1 <BR><BR>var autourl=new array() <BR>autourl[1]="www.njcatv.net" <BR>autourl[2]="javacool.3322.net" <BR>autourl[3]="www.sina.com.cn" <BR>autourl[4]="www.nuaa.edu.cn" <BR>autourl[5]="www.cctv.com" <BR><BR>function butt(){ <BR>document.write("<form name=autof>") <BR>for(var i=1;i<autourl.length;i++) <BR>document.write("<input type=text name=txt"+i+" size=10 value=测试中……> =》<input type=text <BR><BR>name=url"+i+" size=40> =》<input type=button value=go <BR><BR>onclick=window.open(this.form.url"+i+".value)><BR>") <BR>document.write("<input type=submit value=刷新></form>") <BR>} <BR>butt() <BR>function auto(url){ <BR>document.forms[0]["url"+b].value=url <BR>if(tim>200) <BR>{document.forms[0]["txt"+b].value="链接超时"} <BR>else <BR>{document.forms[0]["txt"+b].value="时间"+tim/10+"秒"} <BR>b++ <BR>} <BR>function run(){for(var i=1;i<autourl.length;i++)document.write("<img <BR><BR>src=http://"+autourl+"/"+math.random()+" width=1 height=1 <BR><BR>onerror=auto('http://";;+autourl+"')>")} <BR>run()</script> <BR><BR>37. 各种样式的光标 <BR>auto :标准光标 <BR>default :标准箭头 <BR>hand :手形光标 <BR>wait :等待光标 <BR>text :i形光标 <BR>vertical-text :水平i形光标 <BR>no-drop :不可拖动光标 <BR>not-allowed :无效光标 <BR>help :?帮助光标 <BR>all-scroll :三角方向标 <BR>move :移动标 <BR>crosshair :十字标 <BR>e-resize <BR>n-resize <BR>nw-resize <BR>w-resize <BR>s-resize <BR>se-resize <BR>sw-resize <BR><BR>38.页面进入和退出的特效 <BR>进入页面<meta http-equiv="page-enter" content="revealtrans(duration=x, transition=y)"> <BR>推出页面<meta http-equiv="page-exit" content="revealtrans(duration=x, transition=y)"> <BR>这个是页面被载入和调出时的一些特效。duration表示特效的持续时间,以秒为单位。transition表示使 <BR><BR>用哪种特效,取值为1-23: <BR> 0 矩形缩小 <BR> 1 矩形扩大 <BR> 2 圆形缩小 <BR> 3 圆形扩大 <BR> 4 下到上刷新 <BR> 5 上到下刷新 <BR> 6 左到右刷新 <BR> 7 右到左刷新 <BR> 8 竖百叶窗 <BR> 9 横百叶窗 <BR> 10 错位横百叶窗 <BR> 11 错位竖百叶窗 <BR> 12 点扩散 <BR> 13 左右到中间刷新 <BR> 14 中间到左右刷新 <BR> 15 中间到上下 <BR> 16 上下到中间 <BR> 17 右下到左上 <BR> 18 右上到左下 <BR> 19 左上到右下 <BR> 20 左下到右上 <BR> 21 横条 <BR> 22 竖条 <BR> 23 以上22种随机选择一种 <BR><BR>39.在规定时间内跳转 <BR><meta http-equiv=v="refresh" content="5;url=http://www.51js.com"> <BR><BR>40.网页是否被检索 <BR><meta name="robots" content="属性值"> <BR> 其中属性值有以下一些: <BR> 属性值为"all": 文件将被检索,且页上链接可被查询; <BR> 属性值为"none": 文件不被检索,而且不查询页上的链接; <BR> 属性值为"index": 文件将被检索; <BR> 属性值为"follow": 查询页上的链接; <BR> 属性值为"noindex": 文件不检索,但可被查询链接; <BR> 属性值为"nofollow": 文件不被检索,但可查询页上的链接<BR><BR></SPAN>
|
|