问题描述
我刚刚使用 sandbox
属性创建了一个iFrame。每当我尝试打开一个链接 target =_ blank
或 target =_ top
或当我尝试使用 window.open()
没有任何反应。
I just created an iFrame with the sandbox
attribute. Whenever I try to open a link with target="_blank"
or target="_top"
or when I try to use window.open()
nothing happens.
这是我的代码:
<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>
推荐答案
显然,Chrome允许使用名为<$ c的未记录的沙箱属性要设置$ c> allow-popups 。该属性在Firefox中也受支持,并且是。
Apparently Chrome allows an undocumented sandbox property called allow-popups
to be set. The property is also supported in Firefox and is a Candidate Recommendation on W3C.
allow-popups
让沙盒框架在新窗口或标签中打开链接并且,看起来,当框架尝试打开 target =_ top
的链接时,浏览器将在新选项卡或窗口中打开URL。
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.
这篇关于带有`target =" _blank"`的沙盒iFrame无法打开新选项卡或窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!