//各种尺寸s+=\r\n网页可见区域宽:+document.body.clientWidth;s+=\r\n网页可见区域高:+document.body.clientHeight;s+=\r\n网页可见区域高:+document.body.offsetWeight+(包括边线的宽);s+=\r\n网页可见区域高:+document.body.offsetHeight+(包括边线的宽);s+=\r\n网页正文全文宽:+document.body.scrollWidth;s+=\r\n网页正文全文高:+document.body.scrollHeight;s+=\r\n网页被卷去的高:+document.body.scrollTop;s+=\r\n网页被卷去的左:+document.body.scrollLeft;s+=\r\n网页正文部分上:+window.screenTop;s+=\r\n网页正文部分左:+window.screenLeft;s+=\r\n屏幕分辨率的高:+window.screen.height;s+=\r\n屏幕分辨率的宽:+window.screen.width;s+=\r\n屏幕可用工作区高度:+window.screen.availHeight;s+=\r\n屏幕可用工作区宽度:+window.screen.availWidth;
//过滤数字
//特殊用途
//不缓存
//正则匹配
匹配中文字符的正则表达式:[\u4e00-\u9fa5]匹配双字节字符(包括汉字在内):[^\x00-\xff]匹配空行的正则表达式:\n[\s|]*\r匹配HTML标记的正则表达式:/(.*).*\/\1|(.*)\//匹配首尾空格的正则表达式:(^\s*)|(\s*$)(像vbscript那样的trim函数)匹配Email地址的正则表达式:\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*匹配网址URL的正则表达式:http://([\w-]+\.)+[\w-]+(/[\w-./?%=]*)?以下是例子:利用正则表达式限制网页表单里的文本框输入内容:用正则表达式限制只能输入中文:onkeyup=value=value.replace(/[^\u4E00-\u9FA5]/g,apos;apos;)onbeforepaste=clipboardData.setData(apos;textapos;,clipboardData.getData(apos;textapos;).replace(/[^\u4E00-\u9FA5]/g,apos;apos;))1.用正则表达式限制只能输入全角字符:onkeyup=value=value.replace(/[^\uFF00-\uFFFF]/g,apos;apos;)onbeforepaste=clipboardData.setData(apos;textapos;,clipboardData.getData(apos;textapos;).replace(/[^\uFF00-\uFFFF]/g,apos;apos;))2.用正则表达式限制只能输入数字:onkeyup=value=value.replace(/[^\d]/g,apos;apos;)onbeforepaste=clipboardData.setData(apos;textapos;,clipboardData.getData(apos;textapos;).replace(/[^\d]/g,apos;apos;))3.用正则表达式限制只能输入数字和英文:onkeyup=value=value.replace(/[\W]/g,apos;apos;)onbeforepaste=clipboardData.setData(apos;textapos;,clipboardData.getData(apos;textapos;).replace(/[^\d]/g,apos;apos;))
//消除图像工具栏
IMGSRC=mypicture.jpgHEIGHT=100pxWIDTH=100pxGALLERYIMG=falSEOrheadmetahttp-equiv=imagetoolbarcontent=no/head
//无提示关闭functionClose(){varua=navigator.userAgentvarie=navigator.appName==MicrosoftInternetExplorer?true:falseif(ie){varIEversion=parseFloat(ua.substring(ua.indexOf(MSIE)+5,ua.indexOf(;,ua.indexOf(MSIE))))if(IEversion5.5){varstr=apos;objectid=noTipCloseclassid=clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11apos;str+=apos;paramname=Commandvalue=Close/objectapos;;document.body.insertAdjacentHTML(beforeEnd,str);document.all.noTipClose.Click();}else{window.opener=null;window.close();}}else{window.close()}}
//取得控件得绝对位置(1)scriptlanguage=javascriptfunctiongetoffset(e){vart=e.offsetTop;varl=e.offsetLeft;while(e=e.offsetParent){t+=e.offsetTop;l+=e.offsetLeft;}varrec=newArray(1);rec[0]=t;rec[1]=l;returnrec}/script
//获得控件的绝对位置(2)oRect=obj.getBoundingClientRect();oRect.leftoRect.
//最小化,最大化,关闭
//光标停在文字最后
scriptlanguage=javascriptfunctioncc(){vare=event.srcElement;varr=e.createTextRange();r.moveStart(apos;characterapos;,e.value.length);r.collapse(true);r.select();}/scriptinputtype=textname=text1value=123onfocus=cc()
//页面进入和退出的特效进入页面metahttp-equiv=Page-Entercontent=revealTrans(duration=x,transition=y)推出页面metahttp-equiv=Page-Exitcontent=revealTrans(duration=x,transition=y)这个是页面被载入和调出时的一些特效。duration表示特效的持续时间,以秒为单位。transition表示使用哪种特效,取值为1-23:0矩形缩小1矩形扩大2圆形缩小3圆形扩大4下到上刷新5上到下刷新6左到右刷新7右到左刷新8竖百叶窗9横百叶窗10错位横百叶窗11错位竖百叶窗12点扩散13左右到中间刷新14中间到左右刷新15中间到上下16上下到中间17右下到左上18右上到左下19左上到右下20左下到右上21横条22竖条23
//网页是否被检索
//打印分页
//设置打印objectid=factorystyle=display:noneviewastextclassid=clsid:1663ed61-23eb-11d2-b92f-008048fdd814codebase=http://www.meadroid.com/scriptx/ScriptX.cabn=5,60,0,360/objectinputtype=buttonvalue=页面设置onclick=factory.printing.PageSetup()inputtype=buttonvalue=打印预览onclick=factory.printing.Preview()scriptlanguage=javascriptfunctionwindow.onload(){//--advancedfeaturesfactory.printing.SetMarginMeasure(2)//measuremarginsininchesfactory.printing.SetPageRange(false,1,3)//needpagesfrom1to3factory.printing.printer=HPDeskJet870Cfactory.printing.copies=2factory.printing.collate=truefactory.printing.paperSize=A4factory.printing.paperSource=Manualfeed//--basicfeaturesfactory.printing.header=居左显示b居中显示b居右显示页码,第p页/共P页factory.printing.footer=(自定义页脚)factory.printing.portrait=falsefactory.printing.leftMargin=0.75factory.printing.topMargin=1.5factory.printing.rightMargin=0.75factory.printing.bottomMargin=1.5}functionPrint(frame){factory.printing.Print(true,frame)//printwithprompt}/scriptinputtype=buttonvalue=打印本页onclick=factory.printing.Print(false)inputtype=buttonvalue=页面设置onclick=factory.printing.PageSetup()inputtype=buttonvalue=打印预览onclick=factory.printing.Preview()brahref=http://www.meadroid.com/scriptx/docs/printdoc.htm?statictarget=_blank具体使用手册,更多信息,点这里/a
//自带的打印预览WebBrowser.ExecWB(1,1)打开Web.ExecWB(2,1)关闭现在所有的IE窗口,并打开一个新窗口Web.ExecWB(4,1)保存网页Web.ExecWB(6,1)打印Web.ExecWB(7,1)打印预览Web.ExecWB(8,1)打印页面设置Web.ExecWB(10,1)查看页面属性Web.ExecWB(15,1)好像是撤销,有待确认Web.ExecWB(17,1)全选Web.ExecWB(22,1)刷新Web.ExecWB(45,1)关闭窗体无提示stylemedia=print.Noprint{display:none;}!--用本样式在打印时隐藏非打印项目--.PageNext{page-break-after:always;}!--控制分页--/styleobjectid=WebBrowserwidth=0height=0classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2/objectcenterclass=Noprintinputtype=buttonvalue=打印onclick=document.all.WebBrowser.ExecWB(6,1)inputtype=buttonvalue=直接打印onclick=document.all.WebBrowser.ExecWB(6,6)inputtype=buttonvalue=页面设置onclick=document.all.WebBrowser.ExecWB(8,1)/ppinputtype=buttonvalue=打印预览onclick=document.all.WebBrowser.ExecWB(7,1)/center
//去掉打印时的页眉页脚scriptlanguage=JavaScriptvarHKEY_Root,HKEY_Path,HKEY_Key;HKEY_Root=HKEY_CURRENT_USER;HKEY_Path=\\Software\\Microsoft\\InternetExplorer\\PageSetup\\;//设置网页打印的页眉页脚为空functionPageSetup_Null(){try{varWsh=newActiveXObject(WScript.Shell);HKEY_Key=header;Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,);HKEY_Key=footer;Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,);}catch(e){}}//设置网页打印的页眉页脚为默认值functionPageSetup_Default(){try{varWsh=newActiveXObject(WScript.Shell);HKEY_Key=header;Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,wb页码,p/P);HKEY_Key=footer;Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,ubd);}catch(e){}}/scriptinputtype=buttonvalue=清空页码onclick=PageSetup_Null()inputtype=buttonvalue=恢复页码onclick=PageSetup_Default()
//浏览器验证functioncheckBrowser(){this.ver=navigator.appVersionthis.dom=document.getElementById?1:0this.ie6=(this.ver.indexOf(MSIE6)-1this.dom)?1:0;this.ie5=(this.ver.indexOf(MSIE5)-1this.dom)?1:0;this.ie4=(document.all!this.dom)?1:0;this.ns5=(this.domparseInt(this.ver)=5)?1:0;this.ns4=(document.layers!this.dom)?1:0;this.mac=(this.ver.indexOf(apos;Macapos;)-1)?1:0;this.ope=(navigator.userAgent.indexOf(apos;Operaapos;)-1);this.ie=(this.ie6||this.ie5||this.ie4)this.ns=(this.ns4||this.ns5)this.bw=(this.ie6||this.ie5||this.ie4||this.ns5||this.ns4||this.mac||this.ope)this.nbw=(!this.bw)returnthis;}
//计算内容宽和高
SCRIPTlanguage=javascriptfunctiontest(obj){varrange=obj.createTextRange();alert(内容区宽度:+range.boundingWidth+px\r\n内容区高度:+range.boundingHeight+px);}/SCRIPTBODYTextareaid=txtheight=150sdf/textareaINPUTtype=buttonvalue=计算内容宽度onClick=test(txt)/BODY
//无模式的提示框
functionmodelessAlert(Msg){window.showModelessDialog(javascript:alert(\+escape(Msg)+\);window.close();,,status:no;resizable:no;help:no;dialogHeight:height:30px;dialogHeight:40px;);}
//屏蔽按键
htmlheadmetahttp-equiv=Content-Typecontent=text/html;charset=gb2312noscriptmetahttp-equiv=refreshcontent=0;url=about:noscript/noscripttitle屏蔽鼠标右键、Ctrl+N、Shift+F10、Alt+F4、F11、F5刷新、退格键/title/headbodyscriptlanguage=Javascript!--//屏蔽鼠标右键、Ctrl+N、Shift+F10、F11、F5刷新、退格键//Author:meizz(梅花雨)2002-6-18functiondocument.oncontextmenu(){event.returnValue=false;}//屏蔽鼠标右键functionwindow.onhelp(){returnfalse}//屏蔽F1帮助functiondocument.onkeydown(){if((window.event.altKey)((window.event.keyCode==37)||//屏蔽Alt+方向键←(window.event.keyCode==39)))//屏蔽Alt+方向键→{alert(不准你使用ALT+方向键前进或后退网页!);event.returnValue=false;}/*注:这还不是真正地屏蔽Alt+方向键,因为Alt+方向键弹出警告框时,按住Alt键不放,用鼠标点掉警告框,这种屏蔽方法就失效了。以后若有哪位高手有真正屏蔽Alt键的方法,请告知。*/if((event.keyCode==8)||//屏蔽退格删除键(event.keyCode==116)||//屏蔽F5刷新键(event.ctrlKeyevent.keyCode==82)){//Ctrl+Revent.keyCode=0;event.returnValue=false;}if(event.keyCode==122){event.keyCode=0;event.returnValue=false;}//屏蔽F11if(event.ctrlKeyevent.keyCode==78)event.returnValue=false;//屏蔽Ctrl+nif(event.shiftKeyevent.keyCode==121)event.returnValue=false;//屏蔽shift+F10if(window.event.srcElement.tagName==Awindow.event.shiftKey)window.event.returnValue=false;//屏蔽shift加鼠标左键新开一网页if((window.event.altKey)(window.event.keyCode==115))//屏蔽Alt+F4{window.showModelessDialog(about:blank,,dialogWidth:1px;dialogheight:1px);returnfalse;}}/script屏蔽鼠标右键、Ctrl+N、Shift+F10、Alt+F4、F11、F5刷新、退格键/body/html
//屏蔽打印style@mediaprint{*{display:none}}/style
//移动的图层,拖动1.spanstyle=apos;position:absolute;width:200;height:200;background:redapos;onmousedown=MouseDown(this)onmousemove=MouseMove()onmouseup=MouseUp()meizz/spanscriptlanguage=javascriptvarObj;functionMouseDown(obj){Obj=obj;Obj.setCapture();Obj.l=event.x-Obj.style.pixelLeft;Obj.t=event.y-Obj.style.pixelTop;}functionMouseMove(){if(Obj!=null){Obj.style.left=event.x-Obj.l;Obj.style.top=event.y-Obj.t;}}functionMouseUp(){if(Obj!=null){Obj.releaseCapture();Obj=null;}}/script2.divid=myDivsrc=logo.gifondrag=doDrag();onmouSEOver=this.style.cursor=apos;handapos;style=position:absolute;left=100;top=100;onmousedown=doMouseDown();ahref=#onclick=returnfalseh1wlecome/h1/a/divscriptlanguage=JavaScripttype=text/javascriptvarorgMouseX;varorgMouseY;varorgObjX;varorgObjY;functiondoDrag(){varmyObject=document.all.myDiv;varx=event.clientX;vary=event.clientY;myObject.style.left=x-(orgMouseX-orgObjX);myObject.style.top=y-(orgMouseY-orgObjY);}functiondoMouseDown(){orgMouseX=event.clientX;orgMouseY=event.clientY;orgObjX=parseInt(document.all.myDiv.style.left);orgObjY=parseInt(document.all.myDiv.style.top);}/script
//文档状态改变iframesrc=a.htmlid=fname=fscrolling=noframeborder=0marginwidth=0marginheight=0/iframescriptvardoc=window.frames[f].document;functions(){if(doc.readyState==complete){document.all.f.style.height=doc.body.scrollHeightdocument.all.f.style.width=doc.body.scrollWidth}}doc.onreadystatechange=s/script
//刷新后不变的文本框
0 评论:
发表评论