/////// function getViewportHeight() { if (window.innerHeight!=window.undefined) return window.innerHeight; if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight; if (document.body) return document.body.clientHeight; return window.undefined; } function get_body(){ if (document.documentElement && document.documentElement.scrollTop) { return document.documentElement.body; }else if (document.body) { return document.body; } } function float_to_int(f){ alert(f); var sf=f+''; alert(parseInt(sf.replace(/\.*$/g,''))); return parseInt(sf.replace(/\.*$/g,'')); } function getScroll() { var t, l, w, h; 11. if (document.documentElement && document.documentElement.scrollTop) { t = document.documentElement.scrollTop; l = document.documentElement.scrollLeft; w = document.documentElement.scrollWidth; h = document.documentElement.scrollHeight; } else if (document.body) { t = document.body.scrollTop; l = document.body.scrollLeft; w = document.body.scrollWidth; h = document.body.scrollHeight; } return { t: t, l: l, w: w, h: h }; } function pxParse(stra){ var stra=stra.replace('px',''); return parseInt(stra); } function openSubWindow(params){ if(params.titleMsg==undefined){params.titleMsg='';} if(params.content==undefined){params.content='';} if(params.button1==undefined){params.button1=null;} if(params.button2==undefined){params.button2=null;} if(params.button1_click==undefined){params.button1_click=null;} if(params.button2_click==undefined){params.button2_click=null;} if(params.winWidth==undefined){params.winWidth=null;} if(params.winHeight==undefined){params.winHeight=null;} if(params.borderColor==undefined){params.borderColor=null;} if(params.titleColor==undefined){params.titleColor=null;} if(params.backgroundColor==undefined){params.backgroundColor=null;} if(params.xclose==undefined){params.xclose=null;} var _yu_sub=new SubWindow(params.titleMsg,params.content,params.button1,params.button2,params.button1_click,params.button2_click,params.winWidth,params.winHeight,params.borderColor,params.titleColor,params.backgroundColor,params.xclose,params.button1_params,params.button2_params,params.keep_all,params.closeFunction); document.body.$subwinsubwin=_yu_sub; _yu_sub.show(); return _yu_sub; } function SubWindow(titleMsg,content,button1,button2,button1_click,button2_click,winWidth,winHeight,borderColor,titleColor,backgroundColor,xclose,button1_params,button2_params,keep_all,closeFunction){ if(document.getElementById('winDiv')!=null){ window.yuzm_subwin.close(); } this.titleMsg=titleMsg; //标题信息 this.content=content; //窗体内容 this.button1=button1; this.button2=button2; window.button1_click=button1_click; window.button2_click=button2_click; this.winWidth=winWidth||"400px"; //提示窗口的宽度 this.winHeight=winHeight||"100px"; //提示窗口的高度 this.borderColor=borderColor||"#336699"; //提示窗口的边框颜色 this.titleColor=titleColor||"#336699"; //提示窗口的标题颜色 this.backgroundColor="FFF"; //提示窗口的背景颜色 if(xclose==false){ //关闭按钮是否需要 this.xclose=false; }else{ this.xclose=true; } this.button1_params=button1_params||''; //按钮1的click事件时的参数 this.button2_params=button2_params||''; //按钮2的click事件时的参数 if(keep_all==false){ //内容是否保持原样显示(即宽度超出也不自行回行),默认true(不回行) this.keep_all=false; }else{ this.keep_all=true; } this.closeFunction=closeFunction||function(){window.yuzm_subwin.close();}; if(window.button1_click==null){ window.button1_click=function(){ window.yuzm_subwin.close(); } } if(window.button2_click==null){ window.button2_click=function(){ window.yuzm_subwin.close(); } } window.yuzm_subwin=this; } //显示子窗口 SubWindow.prototype.show=function(){ var subwin=this; //创建模态背景 var bgObj=document.createElement("div"); bgObj.setAttribute('id','bgDiv'); bgObj.style.position="absolute"; //bgObj.style.width=document.body.clientWidth; //bgObj.style.height=document.body.clientHeight; bgObj.style.width="100%"; var fullHeight = getViewportHeight(); if (fullHeight > document.getElementsByTagName("BODY")[0].scrollHeight) { bgObj.style.height = fullHeight; } else { bgObj.style.height = document.getElementsByTagName("BODY")[0].scrollHeight; } bgObj.style.left=0; bgObj.style.top=0; bgObj.style.background="#333333"; //bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=15,finishOpacity=55)"; bgObj.style.filter="Alpha(Opacity=40)"; bgObj.style.opacity="0.4"; bgObj.style.zIndex = "10000"; document.getElementsByTagName("BODY")[0].appendChild(bgObj); bgFrame=document.createElement("iframe"); bgFrame.setAttribute('id','bgFrame'); bgFrame.style.position="absolute"; bgFrame.style.zIndex=-1; //bgFrame.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=15,finishOpacity=55)"; bgFrame.style.filter="Alpha(Opacity=40)"; bgFrame.style.opacity="0.4"; bgFrame.style.width="100%"; bgFrame.style.height="100%"; bgObj.appendChild(bgFrame); //创建子窗口 var winObj=document.createElement("div") winObj.setAttribute("id","winDiv"); winObj.setAttribute("align","center"); winObj.style.position = "absolute"; winObj.style.width = this.winWidth; winObj.style.height = this.winHeight; winObj.style.left = (document.getElementsByTagName("BODY")[0].clientWidth-pxParse(winObj.style.width))/2+getScroll().l; winObj.style.top = (document.getElementsByTagName("BODY")[0].clientHeight-pxParse(winObj.style.height))/2+getScroll().t; winObj.style.backgroundColor=this.backgroundColor; winObj.style.border="1px solid " + this.borderColor; winObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif"; winObj.style.textAlign = "center"; winObj.style.lineHeight ="25px"; winObj.style.zIndex = "10001"; document.getElementsByTagName("BODY")[0].appendChild(winObj); //创建子窗口标题栏 var winTitle=document.createElement("h4"); winTitle.setAttribute("id","winTitle"); winTitle.setAttribute("align","left"); winTitle.style.position="relative"; winTitle.style.height="18px"; winTitle.style.color="white"; winTitle.style.background=this.titleColor; //winTitle.style.border="1px solid " + this.borderColor; winTitle.style.font="12px Verdana, Geneva, Arial, Helvetica, sans-serif"; winTitle.style.margin="0"; winTitle.style.padding="1px"; winTitle.style.cursor="pointer"; winTitle.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);"; winTitle.style.opacity="0.75"; winTitle.innerHTML=this.titleMsg; winTitle.onmousedown=function(evt){ evt=evt || window.event; //var x=evt.layerX; //var y=evt.layerY; window.yu_md_x=evt.clientX; window.yu_md_y=evt.clientY; window.yu_md_dx=pxParse(winObj.style.left); window.yu_md_dy=pxParse(winObj.style.top); winTitle.setCapture(); window.yu_md_move=100; }; winTitle.onmousemove=function(evt){ if(window.yu_md_move!=100){ return false; } if(!evt) evt=window.event; var tx=evt.clientX-window.yu_md_x; var ty=evt.clientY-window.yu_md_y; winObj.style.left=window.yu_md_dx+tx; winObj.style.top=window.yu_md_dy+ty; }; winTitle.onmouseup=function(){ window.yu_md_move=0; winTitle.releaseCapture(); }; document.getElementById("winDiv").appendChild(winTitle); //创建子窗口标题栏上的关闭按钮 if(this.xclose){ var closeBtn=document.createElement("label"); closeBtn.setAttribute("id","closeBtn"); closeBtn.style.position = "absolute"; closeBtn.style.right="4px"; closeBtn.style.top="-4px"; closeBtn.style.fontSize="17px"; closeBtn.innerHTML="x"; closeBtn.onclick=this.closeFunction; document.getElementById("winTitle").appendChild(closeBtn); } //创建子窗口内容 var winContent=document.createElement("div"); winContent.setAttribute("id","winContent"); winContent.style.margin="10px" if(this.keep_all){ winContent.innerHTML="
"+this.content+"
"; }else{ winContent.innerHTML="
"+this.content+"
"; } if(this.button1!=null){ winContent.innerHTML += "
"; } if(this.button2!=null){ winContent.innerHTML += " "; } //+" "; document.getElementById("winDiv").appendChild(winContent); if(this.button1!=null){ document.getElementById('_yu_button_1').onclick=function(){window.button1_click(window.yuzm_subwin.button1_params);}; } if(this.button2!=null){ document.getElementById('_yu_button_2').onclick=function(){window.button2_click(window.yuzm_subwin.button2_params);}; } if(!document.all){document.getElementById("winDiv").style.height=(winContent.offsetHeight+35)+"px";} if(winContent.offsetWidth>winTitle.offsetWidth){ document.getElementById("winDiv").style.width=winContent.offsetWidth+100; } var _overf=document.getElementsByTagName("BODY")[0].style.overflow; document.getElementsByTagName("BODY")[0].style.overflow="hidden"; //alert(document.getElementsByTagName("BODY")[0].clientHeight+"-"+document.getElementsByTagName("BODY")[0].offsetHeight); var ss=document.getElementsByTagName("BODY")[0].clientHeight; document.getElementsByTagName("BODY")[0].style.overflow=_overf; document.getElementById("winDiv").style.left = ((document.getElementsByTagName("BODY")[0].clientWidth-pxParse(document.getElementById("winDiv").style.width))/2+getScroll().l)+'px'; document.getElementById("winDiv").style.top = (((ss-pxParse(document.getElementById("winDiv").style.height))/2+getScroll().t))+'px'; //优化子窗口的模态性 document.onmousemove=function(evt){ evt = evt || window.event; var target=evt.target || evt.srcElement; var winObj=document.getElementById("winDiv"); var node=target; winObj.$isInner=false; while(node){ if(node==winObj){ winObj.$isInner=true; break; } node=node.parentNode; } //if(winObj.$isInner){ // winObj.releaseCapture(); //}else{ // winObj.setCapture(); //} } //winObj.setCapture(); winObj.focus(); if(document.getElementById('_yu_button_1')!=null){ document.getElementById('_yu_button_1').focus(); } } //隐藏子窗口 SubWindow.prototype.close=function(){ if(this.hidden()){ return; } var bgObj=document.getElementById("bgDiv"); var winObj=document.getElementById("winDiv"); winObj.onfocusin=null; document.onmousemove=null; //winObj.releaseCapture(); document.getElementsByTagName("BODY")[0].removeChild(bgObj); document.getElementsByTagName("BODY")[0].removeChild(winObj); } //窗口隐藏状态 SubWindow.prototype.hidden=function(){ var winObj=document.getElementById("winDiv"); if(!winObj){ return true; }else{ return false; } } ///////// //loading info function magtech_loading(info,contextPath){ var info=info||'loading'; if(contextPath){ info='
'+info+'... ...
'; }else{ info='
'+info+'... ...
'; } return openSubWindow({ content:info,winHeight:30,xclose:false }); } //loaded info function magtech_loaded(info,ok){ var info=info||'loaded'; info='
'+info+'
' return openSubWindow({ content:info,button1:ok||'OK' }); } //magtech_alert() function my_alert(message){ window.subwin=new SubWindow("",message,"OK",null,null,null,null,null,null,null,"#dddddd"); document.body.$subwinsubwin=subwin; subwin.show(); } function my_comfrim(message,okClick){ var okClick_1=null; if(okClick!=null){ okClick_1=function(){ window.subwin.close(); okClick(); } } window.subwin=new SubWindow("",message,"OK","cannel",okClick_1,null,null,null,null,null,"#dddddd"); document.body.$subwinsubwin=subwin; subwin.show(); }