【转载】showModalDialog returnValue is undefined in Google Chrome
showModalDialog returnValue is undefined in Google Chrome
For some reason, when using a Javascript showModalDialog from an ASP.NET project, Google Chrome will return an empty (“undefined”) returnValue. This error has been known by the Google Chromium team since 2010, and they have yet to fix it.
Fortunately there is a workaround.
First the modal window:
When closing the modal window it is not enough to set the window.returnValue to the specified return value. Instead, check for the window.opener and set the returnValue there as well:
|
1
2
3
4
5
6
7
|
<script language="javascript" type="text/javascript"> if (window.opener) { window.opener.returnValue = "your return value"; } window.returnValue = "your return value"; self.close();</script> |
Then the window calling the modal window:
To receive the return value from the modal window you need to do this:
|
1
2
3
4
5
6
7
|
window.returnValue = undefined;var result = window.showModalDialog("modalwindow.aspx", window, "dialogHeight:650px; dialogWidth:900px;"); if (result == undefined) result = window.returnValue; if (result != null && result != "undefined") // Do something with the return value // defined in "result" |
This has beed tested in IE9 and Google Chrome 21.0.1180.83 m. According to other sources it will work in later Firefox versions as well.
Further reading:
- javascript – showModalDialog not returning value in Chrome from StackOverflow
- showModalDialog fails to return window.returnValue after being submitted from a form (asp based project) ning value in Chrome from Chromium bug report system.
【转载】showModalDialog returnValue is undefined in Google Chrome的更多相关文章
- Google Chrome浏览器调试入门————转载只为自己查看方便
Google Chrome浏览器调试 作为Web开发人员,我为什么喜欢Google Chrome浏览器 [原文地址:http://www.cnblogs.com/QLeelulu/archive/20 ...
- Google Chrome中的高性能网络-[译]《转载》
以下内容是"The Performance of Open Source Applications" (POSA)的草稿, 也是The Architecture of Open S ...
- [转载]How to Install Google Chrome 39 in CentOS/RHEL 6 and Fedora 19/18
FROM: http://tecadmin.net/install-google-chrome-in-centos-rhel-and-fedora/ Google Chrome is a freewa ...
- 【转载】关于 Google Chrome 中的全屏模式和 APP 模式
[来源于]新浪微博:@阿博 http://www.cnblogs.com/abel/p/3235839.html 全屏模式:kiosk 默认全屏打开一个网页呢,只需要在快捷方式中加上 --kiosk ...
- 详解Google Chrome浏览器(操作篇)(一)
开篇概述 在上篇博客中详解Google Chrome浏览器(理论篇)一文中,主要讲解了Chrome 搜索引擎使用.Chrome安装和基本操作.Chrome 基本架构.多线程等原理性问题,这篇将重点讲解 ...
- 浅谈Google Chrome浏览器(操作篇)(上)
开篇概述 在上篇博客中详解Google Chrome浏览器(理论篇)一文中,主要讲解了Chrome 搜索引擎使用.Chrome安装和基本操作.Chrome 基本架构.多线程等原理性问题,这篇将重点讲解 ...
- 【Google Chrome】 Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource问题解决
问题??打开Google Chrome浏览器报错如下: 结论 浏览器出于安全性考虑,默认对跨域访问禁止 解决方法 给浏览器添加启动参数 --allow-file-access-from-files ...
- IE内嵌google chrome frame解决浏览器兼容问题
IE内嵌google chrome frame解决浏览器兼容问题 http://www.cnblogs.com/xwdreamer/archive/2013/12/17/3477776.html 参 ...
- How to install 64-bit Google Chrome 28+ on 64-bit RHEL/CentOS 6 or 7
How to install 64-bit Google Chrome 28+ on 64-bit RHEL/CentOS 6 or 7 The problem Google developers s ...
随机推荐
- Systemd mysql,nginx,php启动配置文件
systemctl的配置文件目录一般在 /usr/lib/systemd/system/ 或者/etc/systemd/system/ 需要注意的是,nginx与php运行用户必须是root,所以不需 ...
- Java 之NIO
1. NIO 简介 Java NIO(New IO)是从1.4版本开始引入的一个新的IO API,可以替代标准的Java IO API; NIO 与原来的IO有同样的作用和目的,但是使用的方式完全不同 ...
- 网络编程(基于udp协议的套接字/socketserver模块/进程简介)
一.基于UDP协议的套接字 TCP是建立可靠连接,并且通信双方都可以以流的形式发送数据.相对TCP,UDP则是面向无连接的协议. 使用UDP协议时,不需要建立连接,只需要知道对方的IP地址和端口号,就 ...
- android 知识收集
1.无论是 Activity.BroadcastReceiver还是Service,只要是有长时间处理的任务,就需要重新开一个线程来处理,为什么会这样? 因为他们都是运行在主线程中的. 2.在使用Br ...
- Spring-BeanFactory容器
Spring的BeanFactory容器 这是Spring中最简单地容器,它主要的功能是为依赖注入(DI)提供支持.这个容器接口在org.springframework.beans.factory.B ...
- 009-Shell 函数
一.函数定义 linux shell 可以用户定义函数,然后在shell脚本中可以随便调用. shell中函数的定义格式如下: [ function ] funname [()] { action; ...
- windows脚本-CMD和Batch
一.DOS,CMD和batch DOS是磁盘操作系统(英文:Disk Operating System)的缩写,是个人计算机上的一类操作系统.从1981年直到1995年的15年间,DOS在IBM PC ...
- python全栈开发从入门到放弃之面向对象的三大特性
组合 class Course: def __init__(self,name,period,price): self.name = name self.period = period self.pr ...
- 无线路由MAC地址过滤安全可靠性讨论
无线路由MAC地址过滤安全可靠性讨论/如何实现,真的有效吗,如何防范 [内容导航] 什么是MAC地址过滤 突破MAC地址过滤步骤 捕获的无线客户端MAC地址 更改MAC地址来伪造身份 在W ...
- ionic 打包
比如我下载一个官方的小Demoionic start myApp tabs(我默认你已经配置好了安卓的开发环境.安装了全局的ionic.cordova) 首先,你需要给项目添加安卓平台的支持ion ...