【转载】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 ...
随机推荐
- Python--进阶处理5
# 使用路径名来获取文件名,目录名,绝对路径等import ospath = r'F:\myProject\lean\a'# Get the last component of the pathbas ...
- hibernate缓存,四种状态
FlushMode.AUTO:Hibernate判断对象属性有没有改变,是默认的清理模式 FlushMode.COMMIT:在事务结束之前清理Session的缓存,其他任何时候都不清理缓存 Flush ...
- Netty 粘包/半包原理与拆包实战
Java NIO 粘包 拆包 (实战) - 史上最全解读 - 疯狂创客圈 - 博客园 https://www.cnblogs.com/crazymakercircle/p/9941658.html 本 ...
- glibc-2.23_malloc_consolidate_浅析
- HTML 之轮播图
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 都说新的Arraylist 扩容是(1.5倍+1) 看了1.8的源代码发现不是这么回事
都说新的Arraylist 扩容是(1.5倍+1) 看了1.8的源代码发现不是这么回事 就用下面这段代码在jdk的三个版本运行看了下效果 import java.lang.reflect.Field; ...
- linux页缓存
2017-04-25 本节就聊聊页缓存这个东西…… 一.概述 页缓存是一个相对独立的概念,其根本目的是为了加速对后端设备的IO效率,比如文件的读写.页缓存顾名思义是以页为单位的,目前我能想到的在两个地 ...
- point in polygon algorithm
Point-In-Polygon Algorithm — Determining Whether A Point Is Inside A Complex Polygon © 1998,2006,200 ...
- window下的开发环境:常用软件
window下的开发环境:常用软件 Visio 2010 - 产品设计 xmind -产品设计 Axure -产品设计 Edraw max 7.3(破解版) -产品设计 ...
- Push h.264 rawdata to rtmp server
Push h.264 rawdata to rtmp server /* The MIT License (MIT) Copyright (c) 2013-2015 SRS(ossrs) Permis ...