2013-12-11-window.returnvalue兼容性

描述:很多网站通常要通过弹出框选择人、部门、角色等等信息。这个弹出框我们通常采用

var  vReturnValue = window.showModalDialog(sURL [, vArguments] [, sFeatures])的方式实现。

1.vReturnValue 就是子窗体返回的值(子窗体返回值代码:window.returnvalue=你的值)。

2.sURL:你打开的页面。

3.vArguments:可选参数,用来向对话框传递参数。传递的参数类型不限,包括数组等。对话框通过window.dialogArguments来取得传递进来的参数。

4.sFeatures:可选参数,对页面相关属性进行设置。常用属性包括

dialogHeight、 dialogWidth、dialogLeft(距离桌面左的距离)、dialogTop(距离桌面上的距离)、

center( {yes | no | 1 | 0 }窗口是否居中,默认yes)、

help: {yes | no | 1 | 0 }:是否显示帮助按钮,默认yes

resizable: {yes | no | 1 | 0 } [IE5+]:是否可被改变大小。默认no。

status: {yes | no | 1 | 0 } [IE5+]:是否显示状态栏。默认为yes[ Modeless]或no[Modal]。
scroll:{ yes | no | 1 | 0 | on | off }:指明对话框是否显示滚动条。默认为yes。

注意:

这个方法存在浏览器兼容问题。采用ie内核的浏览器支持该方式,但采用谷歌内核的浏览器(如:Chrome)不支持。

不支持表现在window.showModalDialog()方法,采用谷歌内核的浏览器并不是打开一个模式弹出框而是window.open()。这样在弹出框里设置返回值window.returnValue="返回值";在父窗体获取时var  vReturnValue = window.showModalDialog(sURL [, vArguments] [, sFeatures])发现vReturnValue为undefined。

解决方法:

  父窗体部分js代码:

var  vReturnValue = window.showModalDialog('../Main/SelectUser.aspx?radom='+Math.random(), window,'dialogWidth:350px;DialogHeight=400px;status:no;help:no;resizable:yes;'');
        if(vReturnValue==undefined){
            vReturnValue=window.returnValue;
        }


  子窗体部分js代码:

//window.opener != undefined可以判别该浏览器是Chrome浏览器

  if (window.opener != undefined) {

            //for chrome  
            window.opener.returnValue = "opener returnValue";
        }
        else {
            window.returnValue = "window returnValue";
        }
        window.close(); 


  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值