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;

        }

 

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

你可能感兴趣的:(Ajax)