function ShowModalDialog(win,url,a) {
var iframe = document.getElementById("postiframe");
if (!iframe) {
iframe = document.createElement("iframe");
iframe.id = "postiframe";
iframe.name = "postiframe";
iframe.frameborder = "0";
iframe.style.width = "500px";
iframe.style.height = "400px";
}
var myForm = document.createElement("form");
myForm.id = "formtosubmit";
myForm.method = "post"; //使用post方式提交
myForm.action = url+"&isDlg=1"; //以dialog方式打开
myForm.target =iframe.id;
var aInput = document.createElement("input");
aInput.name = "a";
aInput.value = a; //将值赋予这个隐藏的field
var submitInput = document.createElement("input");
submitInput.setAttribute('type', "submit");
myForm.appendChild(aInput);
myForm.appendChild(submitInput);
document.body.appendChild(myForm);
/*var config = {
title: "录入信息",
dialogWidth: 650,
dialogHeight: 450,
maximizable: true,
max: true,
minimizable: true
};*/
var options = {
//url: url,
html:iframe,
title: "",
dialogWidth: 650,
dialogHeight: 450,
maximizable: true,
max: true,
minimizable: true
/*,
dialogReturnValueCallback: DialogCallback */
};
win.showModalDialog(options);
myForm.submit();
document.body.removeChild(myForm);
}
调用代码:
var url = "www.baidu.com";
var win = new ModalDialogWindow();
ShowModalDialog(win,url,a);
结果:1、浏览器新窗口中打开一页面(内容与预期相同)
2、原window中还有一窗口(内容为空 )
预期:不从1窗口中打开 内容在2窗口中展示!
共有三级窗口 我将 myForm.target =iframe.id; 改为 myForm.target =“_self”; 可以在2窗口中展示 但覆盖了二级窗口 关 闭或返回时跳到第一级页面去了