我希望锁定我当前拥有的 iframe。
我想要它,这样任何人都可以将鼠标悬停在它上面,食指就会出现,但它只是禁用了在其中单击的所有功能。我尝试过使用 pointer-events: none;
css 选项,但这会禁用所有内容。
我似乎无法在网上找到任何可以通过 iframe 实现这一点的地方,有什么想法吗?
最佳答案
一个简单的解决方案可能是使用 div 作为 iframe 顶部的捕手,它具有 CSS 属性 cursor:pointer;
,这将模拟指针效果,并且您将阻止该框架内的所有交互iframe。
#catcher {
cursor: pointer;
width: 100%;
height: 100%;
z-index: 1000;
}
<div id="catcher">
<iframe src="https://www.google.com" width="100%" height="100%">
</iframe>
<div>
关于javascript - 仅允许鼠标悬停在 iframe 上(禁止点击),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41955813/