gpt4 book ai didi

Javascript - 如何在使用 iframe、使用 dom 而不是 jquery 时更改页面内的元素内容

转载 作者:搜寻专家 更新时间:2023-11-01 05:26:51 25 4
gpt4 key购买 nike

我有这个 iframe,您可以看到它使用 onload 触发器调用 js 函数。

<iframe name="top" id="top" width="99%" height="20%" src="top.htm" frameborder="0" scrolling="no" onload="log_in()"></iframe>

我需要做的是通过该函数影响“top.htm”中的元素(更改 innerHTML 和类似的东西)。

但问题是该函数无法识别“top.htm”页面的元素,只能识别 index.htm(带有 iframe 的页面)中的元素。

附注我必须使用 DOM,我必须使用 iframe。

有人知道怎么做吗?

10 倍 :-)

最佳答案

例如访问所有dom元素:

document.getElementById("top").contentWindow.document.getElementsByTagName("*")

是你的问题吗?

关于Javascript - 如何在使用 iframe、使用 dom 而不是 jquery 时更改页面内的元素内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2868032/

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