解析js中获得父窗口链接getParent方法以及各种打开窗口的方法

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

解析js中获得父窗口链接getParent方法以及各种打开窗口的方法本篇文章是对js中获得父窗口链接getParent方法以及各种打开窗口的方法进行了详细的分析介绍,需要的朋友参考下复制代码代码如下://打开模态窗口functiondialog(obj){if(obj.url==undefined||obj.url==null){thrownewError(pleasesetobj.url);}varurl=obj.url;if(url.indexOf(?)!=-1){url=url+&r_=+Math.random();}else{url=url+?r_=+Math.random();}//alert(obj.width+,+obj.height+,+obj.top+,+obj.left);varw;if(!obj.width){w=screen.width/2;}else{w=parseInt(obj.width);}varh;if(!obj.height){h=500;}else{h=parseInt(obj.height);}vart;if(!obj.top){t=50;}else{t=parseInt(obj.top);}varl;if(!obj.left){l=(screen.width-parseInt(w))/2;}else{l=parseInt(obj.left);}w=parseInt(w)+px;h=parseInt(h)+px;l=parseInt(l)+px;t=parseInt(t)+px;varparamStr=;paramStr+=(dialogHeight=+h+;);paramStr+=(dialogWidth=+w+;);if(obj.center!=undefined&&obj.center!=null){paramStr+=center=+obj.center+;}else{paramStr+=(dialogTop=+t+;);paramStr+=(dialogLeft=+l+;);}paramStr+=resizable=yes;scroll=yes;//alert(paramStr);varrv=window.showModalDialog(url,window,paramStr);if(rv==undefined){rv=window.returnValue;}if(obj.cb){returnobj.(rv,rv);}returnrv;}functionopenWin(u,w,h){varobj={url:u,width:w,height:h}returndialog(obj);}functionopenWinWithCallBack(u,w,h,fun){varobj={url:u,width:w,height:h,cb:fun}returndialog(obj);}functionopenWindow(obj){if(obj.url==undefined||obj.url==null){thrownewError(pleasesetobj.url);}varurl=obj.url;if(url.indexOf(?)!=-1){url=url+&r_=+Math.random();}else{url=url+?r_=+Math.random();}//alert(obj.width+,+obj.height+,+obj.top+,+obj.left);varw;if(!obj.width){w=screen.width/2;}else{w=parseInt(obj.width);}varh;if(!obj.height){h=500;}else{h=parseInt(obj.height);}vart;if(!obj.top){t=50;}else{t=parseInt(obj.top);}varl;if(!obj.left){l=(screen.width-parseInt(w))/2;}else{l=parseInt(obj.left);}w=parseInt(w);h=parseInt(h);l=parseInt(l);t=parseInt(t);//窗口句柄varname;if(!obj.name){name=win_+newDate().getTime();}else{name=obj.name;}//alert(name);//是否可以改变窗口大小varresizable=obj.resizable||no;//是否有滚动条varscrollbars=obj.scrollbars||yes;//是否有状态栏varstatus=obj.status||no;//是否有菜单栏varmenubar=obj.menubar||no;//是否有工具栏vartoolbar=obj.toolbar||no;//是否有地址栏varlocations=obj.locations||yes;returnwindow.open(url,name,height=+h+,width=+w+,top=+t+,left=+l+,toolbar=+toolbar+,menubar=+menubar+,scrollbars=+scrollbars+,resizable=+resizable+,location=+locations+,status=+status+,hotkeys=esc);}//模态窗口打开模式的子页面获取父页面对象functiongetParent(){varp=;if(window.opener!=undefined){p=window.opener;}else{p=window.dialogArguments;};returnp;}//模态窗口打开模式的子页面设置returnValuefunctionsetReturnValue(v){if(window.opener!=undefined){window.opener.returnValue=v;}else{window.returnValue=v;};}//滑动门functionScrollDoor(){this.value=0;}ScrollDoor.prototype={onlyMenu:function(menus,openClass,closeClass){//onlymenunohavecontentvar_this=this;for(vari=0;imenus.length;i++){_this.$(menus[i]).flag=++this.value;_this.$(menus[i]).value=i;_this.$(menus[i]).onclick=function(){for(varj=0;jmenus.length;j++){_this.$(menus[j]).className=closeClass;//_this.$(divs[j]).style.display=none;}_this.$(menus[this.value]).className=openClass;//_this.$(divs[this.value]).style.=block;}}},sd:function(menus,divs,openClass,closeClass){//twoclassvar_this=this;if(menus.length!=divs.length){alert(菜单层数量和内容层数量不一样!);returnfalse;}for(vari=0;imenus.length;i++){_this.$(menus[i]).flag=++this.value;_this.$(menus[i]).value=i;_this.$(menus[i]).onclick=function(){for(varj=0;jmenus.length;j++){_this.$(menus[j]).className=closeClass;_this.$(divs[j]).style.display=none;}_this.$(menus[this.value]).className=openClass;_this.$(divs[this.value]).style.display=block;}}},sd3class:function(menus,divs,openClass,closeClass,middleClass){//threeclassvar_this=this;for(varx=0;xmenus.length;x++){_this.$(menus[x]).state=_this.$(menus[x]).className==openClass?open:close;}if(menus.length!=divs.length){alert(菜单层数量和内容层数量不一样!);returnfalse;}for(vari=0;imenus.length;i++){_this.$(menus[i]).flag=++this.value;_this.$(menus[i]).value=i;_this.$(menus[i]).onclick=function(){for(varj=0;jmenus.length;j++){_this.$(menus[j]).className=closeClass;_this.$(divs[j]).style.display=none;_this.$(menus[j]).state=close;}this.state=open;_this.$(menus[this.value]).className=openClass;_this.$(divs[this.value]).style.display=block;}_this.$(menus[i]).onmouseover=function(){//alert(this.state);for(varj=0;jmenus.length;j++){if(_this.$(menus[j]).state!=open){_this.$(menus[j]).className=closeClass;_this.$(menus[j]).state=close;}}if(this.state==open){}else{this.className=middleClass;}}_this.$(menus[i]).onmouseout=function(){if(this.state!=open){this.className=closeClass;}}}},$:function(oid){if(typeof(oid)==string)returndocument.getElementById(oid);returnoid;}}

1 / 7
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功