【问题标题】:Google Chrome - iframe sandbox to disable hyperlink submission is not workingGoogle Chrome - 禁用超链接提交的 iframe 沙箱不起作用
【发布时间】:2015-07-10 23:02:39
【问题描述】:

在谷歌浏览器最新稳定版中打开此页面使用(HTTPS,由于其他依赖必须使用HTTPS)https://example.com/test.php

在页面内,我只有这个代码(这是兄弟打印机维护页面):

<iframe sandbox="" id="iframe_display_modules" src="https://192.168.1.57/general/information.html?kind=item"></iframe>

现在,谷歌浏览器不尊重我使用“沙盒”的参数。我可以通过单击 iframe 中的任何链接来使用它,这是不允许的,对吗?

谁能建议我如何阻止用户点击该 iframe?

【问题讨论】:

  • 用户只能看到,但我希望他们无法提交,或者我希望他们不要浏览该 iframe 中的其他链接。

标签: javascript jquery html google-chrome iframe


【解决方案1】:

不幸的是,这不是sandbox 属性所做的事情。它的主要目的是限制子框架在浏览器上操作的能力(例如,阻止它加载到顶部浏览器框架的链接、显示弹出窗口、运行脚本等。)限制用户可以对框架执行的操作。

如果您想阻止用户与框架交互,请考虑在框架顶部显示一个透明元素以防止其接收点击事件:

#frame-holder {
  position: relative;
}

#frame-holder iframe {
  width: 200px;
  height: 100px;
  box-sizing: border-box;
}

#frame-holder div {
  position: absolute;
  width: 200px;
  height: 100px;
  z-index: 1;
}
<div id="frame-holder">
  <div></div>
  <iframe sandbox src="http://example.com/"></iframe>
</div>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-12-12
    • 2015-07-29
    • 1970-01-01
    • 2013-08-25
    • 1970-01-01
    • 2016-03-28
    • 1970-01-01
    相关资源
    最近更新 更多