http://blog.csdn.net/helloboat/article/details/44746503
1、参数传递
通过vArguments来传递参数,类型不限制,对于字符串类型,最大为4096个字符,也可以传递对象。
例:
A.htm
- <script>
- window.showModalDialog("B.htm","这个是参数值","help:no;scroll:no");
- </script>
B.htm
- <script>
- alert("A界面传过来的值是:" + window.dialogArguments);
- </script>
2、返回值
通过window.returnValue向父窗口(即打开模态窗口)返回信息,也可以返回对象。
例:
A.htm
- <script>
- result=window.showModalDialog("B.htm","","help:no;scroll:no");
- alert(result);
- </script>
B.htm
- <script>
- window.returnValue="这里存放返回的结果";
- </script>
3、防止在模态窗口中提交后新开一窗口
在页面的 <body>前加入
- <base target="_self">
4、调用父窗口的方法同时传递参数
A.htm
- <script>
- function show(){//A窗口的方法
- alert("show");
- }
- var arg=new Object();//要传递的参数
- arg.win=window;//把A窗口的引用当参数传进去
- arg.str="argument";//要传进去的其他参数
- window.showModalDialog("B.htm",arg,'help:no');
- </script>
B.htm
- <script>
- var arg=window.dialogArguments;
- alert(arg.str);
- arg.win.show();//调用A窗口的方法
- </script>