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

2024-05-29  本文已影响0人  IssunRadiance

使用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)
上一篇 下一篇

猜你喜欢

热点阅读