当前位置: 代码迷 >> Ajax >> open通过ajax返回的url被浏览器阻止的解决办法
  详细解决方案

open通过ajax返回的url被浏览器阻止的解决办法

热度:123   发布时间:2012-08-28 12:37:01.0
open通过ajax返回的url被浏览器阻止的解决方法

?

window.open打开ajax返回的url,会被浏览器阻止,解决办法:在ajax请创建?var newWindow = window.open(),在ajax的返回后在通过?newWindow.location = url即可解决

?

? ? ? ? var newWindow = window.open('',"new","location=1");

? ? ? ? jQuery.ajax({

? ? ? ? type: "POST",

? ? ? ? url: '/jsshare/to'+type,

? ? ? ? data: postdata,

? ? ? ? dataType: 'text',

? ? ? ? success: function(response){

? ? ? ? ? ? newWindow.location = response;

? ? ? ? }

?

打开新窗口,必须需要点击触发事件, 不能在页面一加载就执行(不然垃圾网站的弹窗搞死人,如果要实现这个功能可以研究这类网站)

  相关解决方案