[英]Sandboxed iFrame with `target=“_blank”` doesn't open new tab or window
I just created an iFrame with the sandbox
attribute. 我刚刚创建了一个带sandbox
属性的iFrame。 Whenever I try to open a link with target="_blank"
or target="_top"
or when I try to use window.open()
nothing happens. 每当我尝试使用target="_blank"
或target="_top"
打开链接时,或者当我尝试使用window.open()
没有任何反应。
Here's my code: 这是我的代码:
<iframe src="http://www.google.com/"
sandbox="allow-top-navigation allow-same-origin allow-forms allow-scripts">
Apparently your browser doesn't support iFrames!
</iframe>
Apparently Chrome allows an undocumented sandbox property called allow-popups
to be set. 显然,Chrome允许设置名为allow-popups
的未记录的沙箱属性。 The property is also supported in Firefox and is a Candidate Recommendation on W3C . 该属性在Firefox中也受支持,并且是W3C的候选推荐标准。
allow-popups
lets the sandboxed frame open links in new windows or tabs and, it appears, when the frame tries to open a link with target="_top"
the browser will open the URL in a new tab or window. allow-popups
允许沙盒框架在新窗口或选项卡中打开链接,当框架尝试打开target="_top"
的链接时,浏览器将在新选项卡或窗口中打开URL。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.