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

来源:互联网 发布:知乎如何成为财务经理 编辑:程序博客网 时间:2024/05/22 13:48

父窗体:

<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>

原创粉丝点击