美文网首页
移动端window.open在苹果手机失效

移动端window.open在苹果手机失效

作者: 花影_62b4 | 来源:发表于2021-08-26 14:47 被阅读0次

因为苹果的安全机制拦截了,所以不能打开新的标签页,

var u = navigator.userAgent;
var isAndroid = u.indexOf("Android") > -1 || u.indexOf("Adr") > -1; //android终端
var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端

 getList().then(res=>{
            if(isAndroid) {  //android终端
                let url = res.data.url;
                window.open(url);
            }else if(isiOS) {   //ios终端
                window.location.href = res.data.url;
            }
})

相关文章

网友评论

      本文标题:移动端window.open在苹果手机失效

      本文链接:https://www.haomeiwen.com/subject/ilkuiltx.html