我有一个用作大按钮的 iframe。 iframe 内的全部内容都是一次点击目标。
我想做的是将一些 HTML 悬停在 iframe 上,就像本例中那样。
<html>
<head>
<style>
iframe {
height: 100px;
width: 300px;
}
div {
position: relative;
}
a {
position: absolute;
top: 0;
left: 0;
}
</style>
</head>
<body>
<div id="content">
<iframe src="frame.html"></iframe>
<a id="text">Image</a>
</div>
</body>
</html>
您还可以在此处查看实例 http://dev.gjcourt.com/iframe
问题是我希望将点击事件从锚定气泡向下放入 iframe 中。有什么办法可以做到这一点吗?
最佳答案
将 iframe 绝对定位,使 iframe 的背景透明,并为其提供高于文本/其他内容的 z-index。
为什么要为此使用 iframe?
关于javascript - 将事件从 HTML 元素冒泡到 iframe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5383619/