`
longgangbai
  • 浏览: 7250371 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

js 父子窗体交互

阅读更多

1>父窗体是使用window.open(url,name,feather)打开子窗体时,使用下面的方法获取。
调用父窗体函数:window.opener.Fun();
调用父窗体物件:window.opener.document.getElementById("txt_test").value

2>子窗体是IFrame的时候,直接用window.parent.Fun或window.parent.Obj

3>父窗体是使用window.showModalDialog(url,arguments,feather)打开子窗体时,使用下面的方法获取。
   1.体在Show子窗体的时候,把当前window对象(只要对象的话用window.document即可)当参数传到子窗体:
      方法如:window.showModalDialog(url,window,"dialogwidth=300px;")
    2.窗体获取这个window对象.var pWin=window.dialogArguments;
    3.同过pWin来调用父窗体函数。(例如 父窗体函数为pFun()); 
 var pwin = window.dialogArguments;
 if(pwin!=undefined){
 var codeStr = "pFun();"
 pwin.execScript(codeStr,"javascript");

当然上面的方法直接等价于pWin.pFun()

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics