我想将另一个页面嵌入到我页面的表格中。有(至少)三种方法可以做到这一点:
<table><tbody><tr>
<td><object id="A" type="text/html" data="othersite.html"></object></td>
<td><embed id="B" src="othersite.html"></td>
<td><iframe id="C" src="othersite.html></iframe></td>
</tr></tbody></table>
但是,我不希望这些嵌入页面响应鼠标单击事件。
我知道安全性阻止我捕获事件:
document.addEventListener("click", function() { console.log("Click captured and discarded"); }, true); // this is forbidden
但我希望能够做类似的事情
document.getElementById("A").disabled = true; // this should work but doesn't
还有其他方法可以让嵌入的html忽略点击事件吗?
谢谢。
附注抱歉,我无法给您提供示例,但 jsfiddle 似乎可以阻止嵌入 html。
最佳答案
您可以在 iframe
顶部放置一个透明的 div
:
iframe, div {
position: absolute;
height: 500px;
width: 500px;
}
<iframe id="C" src="http://wikipedia.com"></iframe>
<div></div>
关于javascript - 禁用嵌入的 html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28240655/