<strong>屏蔽Alt+F4等快捷键: <br></strong><div class="codetitle"> <span><a style="CURSOR: pointer" data="87124" class="copybut" id="copybut87124" onclick="doCopy('code87124')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code87124"> <br><script> <BR>function KeyDown(){ //屏蔽鼠标右键、Ctrl+n、shift+F10、F5刷新、退格键 <BR>//alert("ASCII代码是:"+event.keyCode); <BR>if ((window.event.altKey)&& <BR>((window.event.keyCode==37)|| //屏蔽 Alt+ 方向键 ← <BR>(window.event.keyCode==39))){ //屏蔽 Alt+ 方向键 → <BR>alert("不准你使用ALT+方向键前进或后退网页!"); <BR>event.returnValue=false; <BR>} <BR>if ((event.keyCode==8) || //屏蔽退格删除键 <BR>(event.keyCode==116)|| //屏蔽 F5 刷新键 <BR>(event.keyCode==112)|| //屏蔽 F1 刷新键 <BR>(event.ctrlKey && event.keyCode==82)){ //Ctrl + R <BR>event.keyCode=0; <BR>event.returnValue=false; <BR>} <BR>if ((event.ctrlKey)&&(event.keyCode==78)) //屏蔽 Ctrl+n <BR>event.returnValue=false; <BR>if ((event.shiftKey)&&(event.keyCode==121)) //屏蔽 shift+F10 <BR>event.returnValue=false; <BR>if (window.event.srcElement.tagName == "A" && window.event.shiftKey) <BR>window.event.returnValue = false; //屏蔽 shift 加鼠标左键新开一网页 <BR>if ((window.event.altKey)&&(window.event.keyCode==115)){ //屏蔽Alt+F4 <BR>window.showModelessDialog("about:blank","","dialogWidth:1px;dialogheight:1px"); <BR>return false;} <BR>} <BR>function Showhelp(){ <BR>alert("Wrong!"); <BR>return false; <BR>} <BR></script> <br> </div> <br>============================================================== <br><strong>IE Javascript快捷键操作 <br></strong>1. oncontextmenu="window.event.returnValue=false" 将彻底屏蔽鼠标右键 <br><table border oncontextmenu="return(false)"><td>no</td></table> 可用于Table <br>2. 取消选取、防止复制 <br>3. onpaste="return false" 不准粘贴 <br>4. oncopy="return false;" oncut="return false;" 防止复制 <br>5. <link rel="Shortcut Icon" href="../../../%22favicon.ico%22"> IE地址栏前换成自己的图标 <br>6. <link rel="Bookmark" href="../../../%22favicon.ico%22"> 可以在收藏夹中显示出你的图标 <br>7. <input style="ime-mode:disabled"> 关闭输入法 <br>8. 永远都会带着框架 <br><script language="javascript"><!-- <BR>if (window == top)top.location.href = "frames.htm"; //frames.htm为框架网页 <BR>// --></script> <br>9. 防止被人frame <br><script language="javascript"><!-- <BR>if (top.location != self.location)top.location=self.location; <BR>// --></script> <br>10. <noscript><iframe src="../../*.HTML"></iframe></noscript> 网页将不能被另存为 <br>11. <input type="button" value="查看网页源代码">onclick="window.location = 'view-source:'+ 'http://www.csdn.net/'"> <br>12. 怎样通过ASP的手段来检查来访者是否用了代理 <br>"" then <br>response.write "<font color="#FF0000">您通过了代理服务器,"& _ <br>"真实的IP为"&Request.ServerVariables("HTTP_X_FORWARDED_FOR") <br>end if <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>//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>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>15. 判断上一页的来源 <br>ASP: <br>request.servervariables("HTTP_REFERER") <br>javascript: <br>document.referrer <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><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>17. <br>'定义数据库连接的一些常量 <br>Const adOpenForwardOnly = 0 '游标只向前浏览记录,不支持分页、Recordset、BookMark <br>Const adOpenKeyset = 1 '键集游标,其他用户对记录说做的修改将反映到记录集中,但其他用户增加或删除记录不会反映到记录集中。支持分页、Recordset、BookMark <br>Const adOpenDynamic = 2 '动态游标功能最强,但耗资源也最多。用户对记录说做的修改,增加或删除记录都将反映到记录集中。支持全功能浏览(ACCESS不支持)。 <br>Const adOpenStatic = 3 '静态游标,只是数据的一个快照,用户对记录说做的修改,增加或删除记录都不会反映到记录集中。支持向前或向后移动 <br>Const adLockReadOnly = 1 '锁定类型,默认的,只读,不能作任何修改 <br>Const adLockPessimistic = 2 '当编辑时立即锁定记录,最安全的方式 <br>Const adLockOptimistic = 3 '只有在调用Update方法时才锁定记录集,而在此前的其他操作仍可对当前记录进行更改、插入和删除等 <br>Const adLockBatchOptimistic = 4 '当编辑时记录不会被锁定,而更改、插入和删除是在批处理方式下完成的 <br>Const adCmdText = &H0001 <br>Const adCmdTable = &H0002 <br>%> <br>18. 网页不会被缓存 <br>HTM网页 <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>ASP网页 <br>Response.Expires = -1 <br>Response.ExpiresAbsolute = Now() - 1 <br>Response.cachecontrol = "no-cache" <br>PHP网页 <br>header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); <br>header("Cache-Control: no-cache, must-revalidate"); <br>header("Pragma: no-cache"); <br><br>19. 检查一段字符串是否全由数字组成 <br><script language="javascript"><!-- <BR>function checkNum(str){return str.match(/\D/)==null} <BR>alert(checkNum("1232142141")) <BR>alert(checkNum("123214214a1")) <BR>// --></script> <br>20. 获得一个窗口的大小 <br>document.body.clientWidth,document.body.clientHeight <br>21. 怎么判断是否是字符 <br>if (/[^\x00-\xff]/g.test(s)) alert("含有汉字"); <br>else alert("全是字符"); <br>22.TEXTAREA自适应文字行数的多少 <br><textarea rows="1" name="s1" cols="27" onpropertychange="this.style.posHeight=this.scrollHeight"> <br></textarea> <br>23. 日期减去天数等于第二个日期 <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>24. 选择了哪一个Radio <br><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> <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> <br>25.获得本页url的request.servervariables("")集合 <br>Response.Write "<table border="1"> <!-- Table Header --><tr> <td><b>Variables</b></td> <td><b>value</b></td> </tr>" <br>for each ob in Request.ServerVariables <br>Response.Write "<tr> <td>"&ob&"</td> <td>"&Request.ServerVariables(ob)&"</td> </tr>" <br>next <br>Response.Write "</table>" <br><br>26. <br>本机ip <br>服务器名 <br>服务器IP <br>服务器端口 <br>服务器时间 <br>IIS版本 <br>脚本超时时间 <br>本文件路径 <br>服务器CPU数量 <br>服务器解译引擎 <br>服务器操作系统 <br><br>27.ENTER键可以让光标移到下一个输入框 <br><input onkeydown="if(event.keyCode==13)event.keyCode=9"> <br><br>28. 检测某个网站的链接速度: <br>把如下代码加入区域中: <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 name=url"+i+" size=40> =》<input type=button value=GO onclick=window.open(this.form.url"+i+".value)><br/>") <BR>document.write("<input type=submit value=刷新>") <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 src=http://"+autourl[i]+"/"+Math.random()+" style="max-width:90%"http://";+autourl[i]+"') alt="JavaScript 快捷键设置实现代码_javascript技巧" >")} <BR>run()</script> <br><br>29. 各种样式的光标 <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 </font>