【发布时间】:2021-11-10 15:41:02
【问题描述】:
我有一个内部有 3 个按钮的 iframe,当人们单击 iframe 的特定部分时,我想删除此按钮,而不是单击按钮时,而是单击 iframe 上的特定部分时。当人们点击该部分时,这 3 个按钮必须消失。
这是代码:
<div class="frame-container">
<button class="iframe-button">
<img src="pic_trulli.jpg" alt="Clicca nello spazio verde per andare avanti->">
</button>
<button class="iframe-button2">
<img src="pic_trulli.jpg" alt="I trucchi sono aggiornati e disponibili GRATIS!">
</button>
<button class="iframe-button3">
<img src="pic_trulli.jpg" alt="Registrati adesso per riceverli via EMAIL!">
</button>
<div style="overflow: hidden; margin: -120px auto; max-width:;"><br>
<iframe scrolling="no" width="370" height="363" frameborder="0" target="_self" src="test.com" />
</iframe>
</div>
</div>
.iframe-button {
position: absolute;
top: 180px;
left: 32px;
background-color: #3366cc;
border: none;
color: white;
padding: 21px 10px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 11px;
}
.iframe-button2 {
position: absolute;
top: 88px;
left: 30px;
background-color: #d9d9d9;
border: none;
color: #000000;
padding: 9px 1px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 15px;
}
.iframe-button3 {
position: absolute;
top: 129px;
left: 35px;
background-color: #d9d9d9;
border: none;
color: #000000;
padding: 11px 12.5px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 15px;
}
【问题讨论】:
-
是同源的iframe源吗?
-
@HannaRose 按钮位于 iframe 内。我在 iFrame 中加载了 3 个按钮
-
跨域资源共享 (CORS) 是一种基于 HTTP 标头的机制,它允许服务器指示任何来源(域、方案或端口)。因此,要访问 iframe 中的按钮,它必须是相同的来源。这就是为什么我问它是同一来源的 iframe 源?
标签: javascript html jquery css iframe