window.open在ie下一闪而过问题解决

阅读更多

今天下午遇见了一个windown.open()在ie8下不能下载的问题,现将问题及办法总结一下

具体代码:

    var _dataURL = '/rest/temps/' + _templateData.id + '/down_load_word';
		Y.io(_dataURL,{
			method : 'get',
			sync : true,
			on : {
				success : function (id, o, args){
					var responseData = o.responseText;

                                        window.open(responseData);
				}
			}
		}) 

 具体情况是用YUI的io请求去后台拿到一个文件路径,赋予window.open(),

刚开始没有sync:true这个配置项,在ie下运行的时候总是一闪而过没有弹出下载页面,

后来分析原因可能是:YUI的io请求是异步的,而window.open是同步的,可能有冲突,后然添加配置项sync:true,使YUI的io请求也变成同步的,问题解决

你可能感兴趣的:(window.open,ie8,JavaScript)