今天遇到一个好玩的东西,废话不说,直接看代码:
在test1中调用第二个页面test2:
result = window.showModalDialog(url ,"","dialogTop:0px;dialogLeft:0px;dialogWidth:100px;dialogHeight:100px;status:no;resizable:yes");
test2中,完事儿返回数据(如果在此页中有<form action="" method="post"></form>行为,它会自动打开一个新页面,需要在<head></head>之间加入<base target="_self">,将本页中跳转都需要写成target="",即可。):
window.returnValue ="1,2,3 ";
test1中,回显返回的数据:
if(typeof(result )!='undefined'){
var list = tmp.split(",");
document.form1.KJNAME .value=list[0]; //在页面控件中显示该数据.
...
}
showModalDialog("",window,"");可以利用这个window对象调用 写父页面的方法。在子页中,利用var winOpener = window.dialogArguments;得到这个对象。eg: winOpener.showNum("aaaa");//用来调用你页面的东西。