改写window的模式对话窗口

xiaoxiao2022-09-22  130

弹出模态窗口,采用window.showModalDialog方式弹出窗口输入参数:urlStr(弹出窗口的链接)  winWidth(弹出窗口的宽度,如果输入'0',则默认的宽度为600)   winHeight(弹出窗口的高度,如果输入'0',则默认的高度为400)   postElementName(传入弹出窗口的控件名称,比如一个文本框<input type=text name=text1 value=aa>        要把这个文本框的值传入弹出窗口,则输入text1就可以,弹出窗口用window.dialogArguments方法获取值      如不需要传入参数则输入“@”)  returnFlag(是否返回子页面返回的参数,需要返回参数:true,不需要返回参数:false,弹出窗口用“window.returnValue=”来返回值)function openDialogWin(urlStr,winWidth,winHeight,postElementName,returnFlag){ //获取窗口的高度和宽度 if(winHeight=='0') {  winHeight='600'; } if(winWidth=='0') {  winWidth='400'; }  //获取传入模态窗口的参数 var str=''; if(postElementName!='@') {  var o=document.getElementsByName(postElementName);  for(i=0;i<o.length;i++)  {     if(i==0)      str+=o[i].value;     else      str+=","+o[i].value;    }       }  returnValue=window.showModalDialog(urlStr,str,'scrollbars=yes;resizable=no;help=no;status=no;dialogTop=200;dialogLeft=300;dialogHeight='+winHeight+'px;dialogWidth='+winWidth+'px'); if(returnFlag==true) {  return returnValue; } }

转载请注明原文地址: https://www.6miu.com/read-4977782.html

最新回复(0)