美文网首页
safari浏览器window.open() 不生效

safari浏览器window.open() 不生效

作者: IssunRadiance | 来源:发表于2024-05-29 15:45 被阅读0次

使用window.open() 在 safari 浏览器不生效
是因为 safari 的安全机制将其阻挡了
1.第一种方法,可以生效,不过这样是在当前窗口打开

location.href = "url"
  1. 使用a标签的href
<a :href="url" tatget="_blank">新窗口打开网页</a> 
  1. 网上有人说用以下方法,但是我没有生效
setTimeout(() => window.open( url, '_blank'))
  1. 我当前在用的方法,在成功的回调中获取url,并在新窗口打开
let winOpen = window.open("", "_blank"); //首先打开一个新页面
setTimeout(() => {winOpen.location = url}, 100)

相关文章

网友评论

      本文标题:safari浏览器window.open() 不生效

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