JS常用脚本
1. οncοntextmenu="window.event.returnvalue=false" 将彻底屏蔽鼠标右键 2. <body onselectstart="return false"> 取消选取、防止复制 3. οnpaste="return false" 不准粘贴 4. οncοpy="return false;" oncut="return false;" 防止复制 让弹出窗口总是在最上面: <body οnblur="this.focus();"> 不要滚动条? 让竖条没有: <body style='overflow:scroll;overflow-y:hidden'> </body> 让横条没有: <body style='overflow:scroll;overflow-x:hidden'> </body> 两个都去掉?更简单了 <body scroll="no"> </body> 19. 检查一段字符串是否全由数字组成 <script language="javascript"><!-- function checkNum(str){return str.match(//D/)==null} alert(checkNum("1232142141")) alert(checkNum("123214214a1")) // --></script> 21. 怎么判断是否是字符 if (/[^/x00-/xff]/g.test(s)) alert("含有汉字"); else alert("全是字符"); 本机ip<%=request.servervariables("remote_addr")%> 服务器名<%=Request.ServerVariables("SERVER_NAME")%> 服务器IP<%=Request.ServerVariables("LOCAL_ADDR")%> 服务器端口<%=Request.ServerVariables("SERVER_PORT")%> 服务器时间<%=now%> IIS版本<%=Request.ServerVariables"SERVER_SOFTWARE")%> 脚本超时时间<%=Server.ScriptTimeout%> 本文件路径<%=server.mappath(Request.ServerVariables("SCRIPT_NAME"))%> 服务器CPU数量<%=Request.ServerVariables("NUMBER_OF_PROCESSORS")%> 服务器解译引擎<%=ScriptEngine & "/"& ScriptEngineMajorVersion &"."&ScriptEngineMinorVersion&"."& ScriptEngineBuildVersion %> 服务器操作系统<%=Request.ServerVariables("OS")%> 27.ENTER键可以让光标移到下一个输入框 <input οnkeydοwn="if(event.keyCode==13)event.keyCode=9"> 29. 各种样式的光标 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 sw-resize
时间设置:
function getDatetime(){ var date=new Date(); var year=date.getFullYear(); //获取当前年份 var month=date.getMonth()+1; //获取当前月份 var dat=date.getDate(); //获取当前日 $(".lyear1_date").html( `${year}-${month}-${dat}` ) }
后缀判断视频或者图片:
getFileSuffix: function(filename) { return filename.substring(filename.lastIndexOf('.') + 1).toLowerCase(); }, checkFileType: function(suffix) { var type=""; switch (suffix) { case 'mp4': type = 'mp4'; break; case 'ppt': case 'pptx': case 'doc': case 'docx': case 'pdf': type = 'office'; break; case 'jpg': case 'jpeg': case 'png': case 'bmp': case 'gif': type = 'pic'; break; } return type; }