js参考大全.docx

上传人:b****7 文档编号:10304998 上传时间:2023-02-10 格式:DOCX 页数:149 大小:65.90KB
下载 相关 举报
js参考大全.docx_第1页
第1页 / 共149页
js参考大全.docx_第2页
第2页 / 共149页
js参考大全.docx_第3页
第3页 / 共149页
js参考大全.docx_第4页
第4页 / 共149页
js参考大全.docx_第5页
第5页 / 共149页
点击查看更多>>
下载资源
资源描述

js参考大全.docx

《js参考大全.docx》由会员分享,可在线阅读,更多相关《js参考大全.docx(149页珍藏版)》请在冰豆网上搜索。

js参考大全.docx

js参考大全参考大全事件源对象event.srcElement.tagNameevent.srcElement.type捕获释放event.srcElement.setCapture();event.srcElement.releaseCapture();事件按键event.keyCodeevent.shiftKeyevent.altKeyevent.ctrlKey事件返回值event.returnValue鼠标位置event.xevent.y窗体活动元素document.activeElement绑定事件document.captureEvents(Event.KEYDOWN);访问窗体元素document.all(txt).focus();document.all(txt).select();窗体命令document.execCommand窗体COOKIEdocument.cookie菜单事件document.oncontextmenu创建元素document.createElement(SPAN);根据鼠标获得元素:

document.elementFromPoint(event.x,event.y).tagName=TDdocument.elementFromPoint(event.x,event.y).appendChild(ms)窗体图片document.images索引窗体事件绑定document.onmousedown=scrollwindow;元素document.窗体.elements索引对象绑定事件document.all.xxx.detachEvent(onclick,a);插件数目navigator.plugins取变量类型typeof($js_libpath)=undefined下拉框下拉框.options索引下拉框.options.length查找对象document.getElementsByName(r1);document.getElementById(id);定时timer=setInterval(scrollwindow(),delay);clearInterval(timer);UNCODE编码escape(),unescape父对象obj.parentElement(dhtml)obj.parentNode(dom)交换表的行TableID.moveRow(2,1)替换CSSdocument.all.csss.href=a.css;并排显示display:

inline隐藏焦点hidefocus=true根据宽度换行style=word-break:

break-all自动刷新简单邮件快速转到位置obj.scrollIntoView(true)锚anchors网页传递参数location.search();可编辑obj.contenteditable=true执行菜单命令obj.execCommand双字节字符/x00-xff/汉字/u4e00-u9fa5/让英文字符串超出表格宽度自动换行word-wrap:

break-word;word-break:

break-all;透明背景获得style内容obj.style.cssTextHTML标签document.documentElement.innerHTML第一个style标签document.styleSheets0style标签里的第一个样式document.styleSheets0.rules0防止点击空链接时,页面往往重置到页首端。

word上一网页源asp:

request.servervariables(HTTP_REFERER)javascript:

document.referrer释放内存CollectGarbage();禁止右键document.oncontextmenu=function()returnfalse;禁止保存禁止选取禁止粘贴地址栏图标favicon.ico名字最好不变16*16的16色,放虚拟目录根目录下收藏栏图标查看源码关闭输入法自动全选ENTER键可以让光标移到下一个输入框文本框的默认值title换行obj.title=123sdfs获得时间所代表的微秒varn1=newDate(2004-10-10.replace(/-/g,/).getTime()窗口是否关闭win.closedcheckbox扁平获取选中内容document.selection.createRange().duplicate().text自动完成功能打开该功能关闭该功能窗口最大化无关闭按钮IEwindow.open(aa.htm,meizz,fullscreen=7);统一编码/解码alert(decodeURIComponent(encodeURIComponent(http:

/你好.com?

as=hehe)encodeURIComponent对:

、/、;和?

也编码表格行指示/各种尺寸s+=rn网页可见区域宽:

+document.body.clientWidth;s+=rn网页可见区域高:

+document.body.clientHeight;s+=rn网页可见区域高:

+document.body.offsetWeight+(包括边线的宽);s+=rn网页可见区域高:

+document.body.offsetHeight+(包括边线的宽);s+=rn网页正文全文宽:

+document.body.scrollWidth;s+=rn网页正文全文高:

+document.body.scrollHeight;s+=rn网页被卷去的高:

+document.body.scrollTop;s+=rn网页被卷去的左:

+document.body.scrollLeft;s+=rn网页正文部分上:

+window.screenTop;s+=rn网页正文部分左:

+window.screenLeft;s+=rn屏幕分辨率的高:

+window.screen.height;s+=rn屏幕分辨率的宽:

+window.screen.width;s+=rn屏幕可用工作区高度:

+window.screen.availHeight;s+=rn屏幕可用工作区宽度:

+window.screen.availWidth;/过滤数字/特殊用途/不缓存/正则匹配匹配中文字符的正则表达式:

u4e00-u9fa5匹配双字节字符(包括汉字在内):

x00-xff匹配空行的正则表达式:

ns|*r匹配HTML标记的正则表达式:

/.*|/匹配首尾空格的正则表达式:

(s*)|(s*$)(像vbscript那样的trim函数)匹配Email地址的正则表达式:

w+(-+.w+)*w+(-.w+)*.w+(-.w+)*匹配网址URL的正则表达式:

http:

/(w-+.)+w-+(/w-./?

%&=*)?

以下是例子:

利用正则表达式限制网页表单里的文本框输入内容:

用正则表达式限制只能输入中文:

onkeyup=value=value.replace(/u4E00-u9FA5/g,)onbeforepaste=clipboardData.setData(text,clipboardData.getData(text).replace(/u4E00-u9FA5/g,)1.用正则表达式限制只能输入全角字符:

onkeyup=value=value.replace(/uFF00-uFFFF/g,)onbeforepaste=clipboardData.setData(text,clipboardData.getData(text).replace(/uFF00-uFFFF/g,)2.用正则表达式限制只能输入数字:

onkeyup=value=value.replace(/d/g,)onbeforepaste=clipboardData.setData(text,clipboardData.getData(text).replace(/d/g,)3.用正则表达式限制只能输入数字和英文:

onkeyup=value=value.replace(/W/g,)onbeforepaste=clipboardData.setData(text,clipboardData.getData(text).replace(/d/g,)/消除图像工具栏/无提示关闭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=str+=;document.body.insertAdjacentHTML(beforeEnd,str);document.all.noTipClose.Click();elsewindow.opener=null;window.close();elsewindow.close()/取得控件得绝对位置

(1)functiongetoffset(e)vart=e.offsetTop;varl=e.offsetLeft;while(e=e.offsetParent)t+=e.offsetTop;l+=e.offsetLeft;varrec=newArray

(1);rec0=t;rec1=l;returnrec/获得控件的绝对位置

(2)oRect=obj.getBoundingClientRect();oRect.leftoRect./最小化,最大化,关闭/光标停在文字最后functioncc()vare=event.srcElement;varr=e.createTextRange();r.moveStart(character,e.value.length);r.collapse(true);r.select();/页面进入和退出的特效进入页面推出页面这个是页面被载入和调出时的一些特效。

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/网页是否被检索/打印分页/设置打印functionwindow.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.5functionPrint(frame)factory.printing.Print(true,frame)/printwithprompt具体使用手册,更多信息,点这里/自带的打印预览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)关闭窗体无提示.Noprintdisplay:

none;.PageNextpage-break-after:

always;/去掉打印时的页眉页脚varHKEY_Root,HKEY_Path,HKEY_Key;HKEY_Root=HKEY_CURRENT_USER;HKEY_Path=SoftwareMicrosoftInternetExplorerPageSetup;/设置网页打印的页眉页脚为空functionPageSetup_Null()tryvarWsh=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()tryvarWsh=newActiveXObject(WScript.Shell);HKEY_Key=header;Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,&w&b页码,&p/&P);HKEY_Key=footer;Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,&u&b&d);catch(e)/浏览器验证functioncheckBrowser()this.ver=navigator.appVersionthis.dom=document.getElementById?

1:

0this.ie6=(this.ver.indexOf(MSIE6)-1&this.dom)?

1:

0;this.ie5=(this.ver.indexOf(MSIE5)-1&this.dom)?

1:

0;this.ie4=(document.all&!

this.dom)?

1:

0;this.ns5=(this.dom&parseInt(this.ver)=5)?

1:

0;this.ns4=(document.layers&!

this.dom)?

1:

0;this.mac=(this.ver.indexOf(Mac)-1)?

1:

0;this.ope=(navigator.userAgent.indexOf(Opera)-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;/计算内容宽和高functiontest(obj)varrange=obj.createTextRange();alert(内容区宽度:

+range.boundingWidth+pxrn内容区高度:

+range.boundingHeight+px);sdf/无模式的提示框/屏蔽按键屏蔽鼠标右键、Ctrl+N、Shift+F10、Alt+F4、F11、F5刷新、退格键!

-/屏蔽鼠标右键、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.ctrlKey&event.keyCode=82)/Ctrl+Revent.keyCode=0;event.returnValue=false;if(event.keyCode=122)event.keyCode=0;event.returnValue=false;/屏蔽F11if(event.ctrlKey&event.keyCode=78)event.returnValue=false;/屏蔽Ctrl+nif(event.shiftKey&event.keyCode=121)event.returnValue=false;/屏蔽shift+F10if(window.event.srcElement.tagName=A&window.event.shiftKey)window.event.returnValue=false;/屏蔽shift加鼠标左键新开一网页if(window.event.altKey)&(window.event.keyCode=115)/屏蔽Alt+F4window.showModelessDialog(about:

blank,dialogWidth:

1px;dialogheight:

1px);returnfalse;屏蔽鼠标右键、Ctrl+N、Shift+F10、Alt+F4、F11、F5刷新、退格键/屏蔽打印mediaprint*display:

none/移动的图层,拖动1.meizzvarObj;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;2.wlecomevarorgMouseX;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);/文档状态改变vardoc=window.framesf.document;functions()if(doc.readyState=complete)document.all.f.style.height=doc.body.scrollHeightdocument.all.f.style.width=doc.body.scrollWidthdoc.onreadystatechange=s/刷新后不变的文本框/访问剪贴板/操作COOKIEfunctionSetCookie(sName,sValue)document.cookie=sName+=+escape(sValue)+;functionGetCookie(sName)varaCookie=document.cookie.split(;);for(vari=0;iaCookie.length;i+)varaCrumb=aCookiei.split(=);if(sName=aCrumb0)returnunescape(aCrumb1);functionDelCookie(sName)document.cookie=sName+=+escape(sValue)+;expires=Fri,31Dec199923:

59:

59GMT;/setTimeout增加参数var_st=window.setTimeout;window.setTimeout=function(fRef,mDelay)if(typeoffRef=function)varargu=Array.prototype.slice.call(arguments,2);varf=(function()fRef.apply(null,argu););return_st(f,mDelay);return_st(fRef,mDelay);functiontest(x)alert(x);window.setTimeout(test,1000,fason);/自定义的apply,callFunction.prototype.apply=function(obj,argu)if(obj)obj.constructor.prototype._caller=this;varargus=newArray();for(vari=0;iargu.length;i+)argusi=argu+i+;varr;eval(r=+(obj?

(obj._caller(+argus.join(,)+);):

(this(+

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 军事

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1