【发布时间】:2013-07-19 09:22:54
【问题描述】:
假设我在网站上有一个嵌入式网页(例如:www.en.wikipedia.org/wiki/Pulsar)。用户点击文章内的超链接(例如: https://en.wikipedia.org/wiki/Extrasolar_planet)。
当用户单击原始文章(“Pulsar”)中的条目时,我想要一个显示文章名称(在本例中为“系外行星”)的框架
我怎么知道用户点击了什么?
编辑:在看到许多示例后,我尝试这样做,但效果不佳。
<iframe width="940" height="550" src="http://en.wikipedia.org/wiki/Special:Random"> </iframe>
<script>
(document.getElementsByTagName('iframe').contentWindow.document).keydown = function() {
alert("Hello World")
})
</script>
【问题讨论】:
-
您可以在 iframe 中附加事件侦听器,例如 this。
标签: javascript html css ruby-on-rails