window.showModalDialog 应用

http://blog.csdn.net/helloboat/article/details/44746503

1、参数传递 
通过vArguments来传递参数,类型不限制,对于字符串类型,最大为4096个字符,也可以传递对象。

例: 
A.htm

[html]  view plain copy print ? 在CODE上查看代码片 派生到我的代码片
  1. <script>  
  2.     window.showModalDialog("B.htm","这个是参数值","help:no;scroll:no");  
  3. </script>  

B.htm

[html]  view plain copy print ? 在CODE上查看代码片 派生到我的代码片
  1. <script>  
  2.     alert("A界面传过来的值是:" + window.dialogArguments);  
  3. </script>   

2、返回值 
通过window.returnValue向父窗口(即打开模态窗口)返回信息,也可以返回对象。

例: 
A.htm

[html]  view plain copy print ? 在CODE上查看代码片 派生到我的代码片
  1. <script>  
  2.     result=window.showModalDialog("B.htm","","help:no;scroll:no");  
  3.     alert(result);  
  4. </script>  

B.htm

[html]  view plain copy print ? 在CODE上查看代码片 派生到我的代码片
  1. <script>  
  2.     window.returnValue="这里存放返回的结果";  
  3. </script>   

3、防止在模态窗口中提交后新开一窗口

在页面的 <body>前加入

[html]  view plain copy print ? 在CODE上查看代码片 派生到我的代码片
  1. <base target="_self">  

4、调用父窗口的方法同时传递参数

A.htm 

[html]  view plain copy print ? 在CODE上查看代码片 派生到我的代码片
  1. <script>  
  2.     function show(){//A窗口的方法  
  3.          alert("show");  
  4.     }  
  5.     var arg=new Object();//要传递的参数  
  6.     arg.win=window;//把A窗口的引用当参数传进去  
  7.     arg.str="argument";//要传进去的其他参数  
  8.     window.showModalDialog("B.htm",arg,'help:no');  
  9. </script>  

B.htm

[html]  view plain copy print ? 在CODE上查看代码片 派生到我的代码片
  1. <script>  
  2.     var arg=window.dialogArguments;  
  3.     alert(arg.str);  
  4.     arg.win.show();//调用A窗口的方法  
  5. </script>  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值