zoukankan      html  css  js  c++  java
  • 解决在Chrome下无法获取showModalDialog返回值的问题

    今天发送的bug,正常情况下用IE和FF测试showModalDialog方法,在子页面将处理的结果赋值给window.returnValue,关闭子页面,在父页面可以通过var result=window.showModalDialog(…)获取到结果。

    但chrome下result是undefine。

    解决的办法就是,在设置返回结果时,也为window.opener.returnValue赋值。

     1: //父页面调用showModalDialog
     2: var result = window.showModelDialog(....);
     3:  
     4: //for chrome
     5: if(!result)
     6: {
     7:  result=window.returnValue;
     8: }
     9:  
     10: if(result)
     11: {
     12:  //IE/FF/CHROME都可以正常使用result
     13: }
     14:  
     15:  
     16:  
     17: //子页面
     18: var resultObj = {Pass:true};
     19: if(window.opener)
     20: {
     21:  window.opener.returnValue=resultObj;
     22: }
     23: window.returnValue=resultObj;
  • 相关阅读:
    你读了该博客中哪些超链接?有何感想
    最理想的师生关系是健身教练和学员的关系,在这种师生关系中你期望获得来自老师的哪些帮助?
    1500802028 王莉娟
    解码方法
    N皇后问题
    两个链表的交叉
    全排列
    交叉字符串
    翻转链表
    爬楼梯
  • 原文地址:https://www.cnblogs.com/ricksun/p/2768374.html
Copyright © 2011-2022 走看看