代码源自网络,并自己整理吸收,调试通过
function openModal() { popupDialog('child.html',200,200); } function showMsg(obj) { alert(obj); } function popupDialog(url,width,height) { var x = parseInt(screen.width / 2.0) - (width / 2.0); var y = parseInt(screen.height / 2.0) - (height / 2.0); var isMSIE= (navigator.appName == "Microsoft Internet Explorer"); //判断浏览器 if (isMSIE) { retval = window.showModalDialog(url, window, "dialogWidth:"+width+"px; dialogHeight:"+height+"px; dialogLeft:"+x+"px; dialogTop:"+y+"px; status:no; directories:yes;scrollbars:no;Resizable=no; " ); } else { var win = window.open(url, "mcePopup", "top=" + y + ",left=" + x + ",scrollbars=" + scrollbars + ",dialog=yes,modal=yes,width=" + width + ",height=" + height + ",resizable=no" ); eval('try { win.resizeTo(width, height); } catch(e) { }'); win.focus(); } }
function doReload() { var isMSIE= (navigator.appName == "Microsoft Internet Explorer"); if (isMSIE) { //IE //parent.dialogArguments.location.reload(); parent.dialogArguments.showMsg("345"); } else { //FF //parent.opener.document.location.reload(); window.opener.showMsg("345"); } //关闭窗口用的是 top.close(); 这个IE、FireFox都支持。 //top.close(); window.close(); }