使用rel =“noopener”在window.open()中 [英] Using rel="noopener" in window.open()

查看:1132
本文介绍了使用rel =“noopener”在window.open()中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我知道我可以在 c $ c c> target =_ blank。但我试图将它作为参数传递给 window.open(),即:

So I know that I can apply rel="noopener in an a tag when using target="_blank". But I'm trying to pass it as an argument to window.open(), ie:

window.open('http://cats.com','_ blank','rel = noopener' )

然而它似乎没有像我预期的那样工作,因为开启者对象。

however it doesn't seem to be working the way that I expected, as the opener object still exists on the window after the user clicks on the link.

有什么东西我不见了吗?或者不能不这样做我打算?

Is there something I'm missing? Or cannot it not be done the way that I'm intending?

我发现了一些很棒的文章,但就我所知,它们并没有完全解决我的用例。

I've found some great articles but they don't quite address my use case as far as I can tell.

https:// developer。 mozilla.org/en-US/docs/Web/API/Window/open
https://mathiasbynens.github.io/rel -noopener /

非常感谢。

推荐答案

这对我有用:

const a = document.createElement("a")
a.href = args.url
a.target = "_blank"
a.rel = "noopener"
a.click()

这篇关于使用rel =“noopener”在window.open()中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆