解决returnValue问题
通过以上的种种测试,我们已经知道chrome的showModalDialog方法很像执行了window.open方法,那么我们可以利用window.opener来实现window.returnValue的功能。
父窗体部分js代码:
- var returnValue = window.showModalDialog("son.html ", window);
- //for chrome
- if (returnValue == undefined) {
- returnValue = window.returnValue;
- }
子窗体部分js代码:
- if (window.opener != undefined) {
- //for chrome
- window.opener.returnValue = "opener returnValue";
- }
- else {
- window.returnValue = "window returnValue";
- }
- window.close();
这样也在IE,FireFox,Chrome,Safari等浏览器下都可以通用了。
转自:http://www.cnblogs.com/chopper/archive/2012/06/25/2556266.html