gpt4 book ai didi

javascript - 检测嵌入式网页上的点击

转载 作者:太空宇宙 更新时间:2023-11-04 14:47:24 24 4
gpt4 key购买 nike

假设我在网站上有一个嵌入式网页(示例:www.en.wikipedia.org/wiki/Pulsar)。用户点击文章内的超链接(例如: https://en.wikipedia.org/wiki/Extrasolar_planet ).

当用户单击原始文章(“Pulsar”)中的条目时,我想要一个显示文章名称(在本例中为“Extrasolar planet”)的框架

我如何知道用户点击了什么?

编辑:看了很多例子后,我尝试这样做,但效果不佳。

<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>

最佳答案

这不起作用,因为您正在使用返回数组的 getElementsByTagName。请改用 getElementByIdgetElementsByTagName('iframe')[0]

关于javascript - 检测嵌入式网页上的点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17742504/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com