最新矢量花纹素材免费下载 房地产矢量logo大全下载
返回列表 回复 发帖

40个实用经典的网页特效代码

  
            <STRONG><BR><BR></STRONG><SPAN style="FONT-SIZE: 12px">1. oncontextmenu="window.event.returnvalue=false" 将彻底屏蔽鼠标右键 <BR>&lt;table border oncontextmenu=return(false)&gt;&lt;td&gt;no&lt;/table&gt; 可用于table <BR><BR>2. &lt;body onselectstart="return false"&gt; 取消选取、防止复制 <BR><BR>3. onpaste="return false" 不准粘贴 <BR><BR>4. oncopy="return false;" oncut="return false;" 防止复制 <BR><BR>5. &lt;link rel="shortcut icon" href="favicon.ico"&gt; ie地址栏前换成自己的图标 <BR><BR>6. &lt;link rel="bookmark" href="favicon.ico"&gt; 可以在收藏夹中显示出你的图标 <BR><BR>7. &lt;input style="ime-mode:disabled"&gt; 关闭输入法 <BR><BR>8. 永远都会带着框架 <BR>&lt;script language="javascript"&gt;&lt;!-- <BR>if (window == top)top.location.href = "frames.htm"; //frames.htm为框架网页 <BR>// --&gt;&lt;/script&gt; <BR><BR>9. 防止被人frame <BR>&lt;script language=javascript&gt;&lt;!-- <BR>if (top.location != self.location)top.location=self.location; <BR>// --&gt;&lt;/script&gt; <BR><BR>10. 网页将不能被另存为 <BR>&lt;noscript&gt;&lt;iframe src=*.html&gt;&lt;/iframe&gt;&lt;/noscript&gt; <BR><BR>11. &lt;input type=button value=查看网页源代码 <BR>onclick="window.location = 'view-source:'+ 'http://www.51js.com/&amp;#39;"&gt; <BR><BR>12.删除时确认 <BR>&lt;a href='javascript:if(confirm("确实要删除吗?"))location="boos.asp?&amp;areyou=删除&amp;page=1"'&gt;删 <BR><BR>除&lt;/a&gt; <BR><BR>13. 取得控件的绝对位置 <BR>//javascript <BR>&lt;script language="javascript"&gt; <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>&lt;/script&gt; <BR><BR>//vbscript <BR>&lt;script language="vbscript"&gt;&lt;!-- <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&lt;&gt;"body" <BR>set a = a.offsetparent <BR>t=t+a.offsettop <BR>l=l+a.offsetleft <BR>wend <BR>msgbox "top="&amp;t&amp;chr(13)&amp;"left="&amp;l,64,"得到控件的位置" <BR>end function <BR>--&gt;&lt;/script&gt; <BR><BR>14. 光标是停在文本框文字的最后 <BR>&lt;script language="javascript"&gt; <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>&lt;/script&gt; <BR>&lt;input type=text name=text1 value="123" onfocus="cc()"&gt; <BR><BR>15. 判断上一页的来源 <BR>javascript: <BR>document.referrer <BR><BR>16. 最小化、最大化、关闭窗口 <BR>&lt;object id=hh1 classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"&gt; <BR>&lt;param name="command" value="minimize"&gt;&lt;/object&gt; <BR>&lt;object id=hh2 classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"&gt; <BR>&lt;param name="command" value="maximize"&gt;&lt;/object&gt; <BR>&lt;object id=hh3 classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"&gt; <BR>&lt;param name="command" value="close"&gt;&lt;/object&gt; <BR><BR>&lt;input type=button value=最小化 onclick=hh1.click()&gt; <BR>&lt;input type=button value=最大化 onclick=hh2.click()&gt; <BR>&lt;input type=button value=关闭 onclick=hh3.click()&gt; <BR>本例适用于ie <BR><BR>17.屏蔽功能键shift,alt,ctrl <BR>&lt;script&gt; <BR>function look(){ <BR>if(event.shiftkey) <BR>alert("禁止按shift键!"); //可以换成alt ctrl <BR>} <BR>document.onkeydown=look; <BR>&lt;/script&gt; <BR><BR>18. 网页不会被缓存 <BR>&lt;meta http-equiv="pragma" content="no-cache"&gt; <BR>&lt;meta http-equiv="cache-control" content="no-cache, must-revalidate"&gt; <BR>&lt;meta http-equiv="expires" content="wed, 26 feb 1997 08:21:57 gmt"&gt; <BR>或者&lt;meta http-equiv="expires" content="0"&gt; <BR><BR>19.怎样让表单没有凹凸感? <BR>&lt;input type=text style="border:1 solid #000000"&gt; <BR>或 <BR>&lt;input type=text style="border-left:none; border-right:none; border-top:none; border-bottom: <BR><BR>1 solid #000000"&gt;&lt;/textarea&gt; <BR><BR>20.&lt;div&gt;&lt;span&gt;&amp;&lt;layer&gt;的区别? <BR>&lt;div&gt;(division)用来定义大段的页面元素,会产生转行 <BR>&lt;span&gt;用来定义同一行内的元素,跟&lt;div&gt;的唯一区别是不产生转行 <BR>&lt;layer&gt;是ns的标记,ie不支持,相当于&lt;div&gt; <BR><BR><BR>21.让弹出窗口总是在最上面: <BR>&lt;body onblur="this.focus();"&gt; <BR><BR>22.不要滚动条? <BR>让竖条没有: <BR>&lt;body style='overflow:scroll;overflow-y:hidden'&gt; <BR>&lt;/body&gt; <BR>让横条没有: <BR>&lt;body style='overflow:scroll;overflow-x:hidden'&gt; <BR>&lt;/body&gt; <BR>两个都去掉?更简单了 <BR>&lt;body scroll="no"&gt; <BR>&lt;/body&gt; <BR><BR>23.怎样去掉图片链接点击后,图片周围的虚线? <BR>&lt;a href="#" onfocus="this.blur()"&gt;&lt;img src="logo.jpg" border=0&gt;&lt;/a&gt; <BR><BR>24.电子邮件处理提交表单 <BR>&lt;form name="form1" method="post" action="mailto:****@***.com" enctype="text/plain"&gt; <BR>&lt;input type=submit&gt; <BR>&lt;/form&gt; <BR><BR>25.在打开的子窗口刷新父窗口的代码里如何写? <BR>window.opener.location.reload() <BR><BR>26.如何设定打开页面的大小 <BR>&lt;body onload="top.resizeto(300,200);"&gt; <BR>打开页面的位置&lt;body onload="top.moveby(300,200);"&gt; <BR><BR>27.在页面中如何加入不是满铺的背景图片,拉动页面时背景图不动 <BR>&lt;style&gt; <BR>body <BR>{background-image:url(logo.gif); background-repeat:no-repeat; <BR><BR>background-position:center;background-attachment: fixed} <BR>&lt;/style&gt; <BR><BR>28. 检查一段字符串是否全由数字组成 <BR>&lt;script language="javascript"&gt;&lt;!-- <BR>function checknum(str){return str.match(//d/)==null} <BR>alert(checknum("1232142141")) <BR>alert(checknum("123214214a1")) <BR>// --&gt;&lt;/script&gt; <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>&lt;textarea rows=1 name=s1 cols=27 onpropertychange="this.style.posheight=this.scrollheight"&gt; <BR>&lt;/textarea&gt; <BR><BR>32. 日期减去天数等于第二个日期 <BR>&lt;script language=javascript&gt; <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>&lt;/script&gt; <BR><BR>33. 选择了哪一个radio <BR>&lt;html&gt;&lt;script language="vbscript"&gt; <BR>function checkme() <BR>for each ob in radio1 <BR>if ob.checked then window.alert ob.value <BR>next <BR>end function <BR>&lt;/script&gt;&lt;body&gt; <BR>&lt;input name="radio1" type="radio" value="style" checked&gt;style <BR>&lt;input name="radio1" type="radio" value="barcode"&gt;barcode <BR>&lt;input type="button" value="check" onclick="checkme()"&gt; <BR>&lt;/body&gt;&lt;/html&gt; <BR><BR>34.脚本永不出错 <BR>&lt;script language="javascript"&gt; <BR>&lt;!-- hide <BR>function killerrors() { <BR>return true; <BR>} <BR>window.onerror = killerrors; <BR>// --&gt; <BR>&lt;/script&gt; <BR><BR>35.enter键可以让光标移到下一个输入框 <BR>&lt;input onkeydown="if(event.keycode==13)event.keycode=9"&gt; <BR><BR>36. 检测某个网站的链接速度: <BR>把如下代码加入&lt;body&gt;区域中: <BR>&lt;script language=javascript&gt; <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("&lt;form name=autof&gt;") <BR>for(var i=1;i&lt;autourl.length;i++) <BR>document.write("&lt;input type=text name=txt"+i+" size=10 value=测试中……&gt; =》&lt;input type=text <BR><BR>name=url"+i+" size=40&gt; =》&lt;input type=button value=go <BR><BR>onclick=window.open(this.form.url"+i+".value)&gt;<BR>") <BR>document.write("&lt;input type=submit value=刷新&gt;&lt;/form&gt;") <BR>} <BR>butt() <BR>function auto(url){ <BR>document.forms[0]["url"+b].value=url <BR>if(tim&gt;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&lt;autourl.length;i++)document.write("&lt;img <BR><BR>src=http://"+autourl+"/"+math.random()+" width=1 height=1 <BR><BR>onerror=auto('http://";;+autourl+"')&gt;")} <BR>run()&lt;/script&gt; <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>进入页面&lt;meta http-equiv="page-enter" content="revealtrans(duration=x, transition=y)"&gt; <BR>推出页面&lt;meta http-equiv="page-exit" content="revealtrans(duration=x, transition=y)"&gt;  <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>&lt;meta http-equiv=v="refresh" content="5;url=http://www.51js.com"&gt; <BR><BR>40.网页是否被检索 <BR>&lt;meta name="robots" content="属性值"&gt; <BR>  其中属性值有以下一些: <BR>  属性值为"all": 文件将被检索,且页上链接可被查询; <BR>  属性值为"none": 文件不被检索,而且不查询页上的链接; <BR>  属性值为"index": 文件将被检索; <BR>  属性值为"follow": 查询页上的链接; <BR>  属性值为"noindex": 文件不检索,但可被查询链接; <BR>  属性值为"nofollow": 文件不被检索,但可查询页上的链接<BR><BR></SPAN>            
返回列表