当前位置: 代码迷 >> Web前端 >> 形式窗体调用用父窗体中的方法
  详细解决方案

形式窗体调用用父窗体中的方法

热度:171   发布时间:2012-10-19 16:53:36.0
模式窗体调用用父窗体中的方法

父窗体:

<script type="text/javascript">
function a(){
var strs=new Array();
strs[0]=window;
strs[1]="yang";
window.showModalDialog("b.jsp",strs,"dialogWidth:600px; dialogHeight:380px; status:no; help:yes");
}
function b(){
alert("父窗体中的方法b()");
}
</script>
</head>

<body>
<input type="button" value="测试" onclick="a();"/>
</body>

模式窗体(b.jsp):

<script type="text/javascript">
var strs=window.dialogArguments;
//strs[0]:window
//strs[1]:yang


function c(){
var obj1=strs[1];
alert("参数二是"+obj1);
if(obj1=="yang"){
strs[0].b();//调用父窗体中的方法
}
}
</script>
</head>

<body>
<input type="button" onclick="c()" value="测试二"/>
</body>

  相关解决方案