以前很多网页都使用如下脚本来打开对话框,这脚本只能在IE下使用,对于某些浏览器来说完全不兼容。
var returnValue =
window.showModalDialog(url,'',features);
最近在做浏览器兼容的工作,必须把这些不兼容的问题一一解决掉。针对此问题,修改如下:
1、在父窗体的脚本:
var winNew=null;
function openNewWin(url) {
if(winNew
&& winNew.open && !winNew.closed){
winNew.focus();
return false;
}
var myDate =
new Date();
var intWidth
= 670;
var
intHeight = 500;
var intX =
(screen.availWidth - intWidth) / 2;
var intY =
(screen.availHeight - intHeight) / 2;
var
strFeatures =
'resizable=no,status=no,scrollbars=yes,model=yes,width=' + intWidth
+ ',height=' + intHeight + ',left=' + intX + ',top=' + intY;
winNew = window.open(url,
'newWin', strFeatures);
winNew.focus();
}
2、在弹出窗体的脚本:
var winParent =
window.opener;
winParent.winNew =
window;
//如果要改变父窗体的元素值,可以通过如下脚本实现
var winP = window.winParent.document;
winP.getElementById('元素id').value =
'.....';