gpt4 book ai didi

javascript - 尝试从 iframe 中获取 div,然后将其放入我自己网站上的 div 中

转载 作者:行者123 更新时间:2023-11-28 08:39:31 25 4
gpt4 key购买 nike

我正在尝试从网站 http://www.w3schools.com/js/ 中提取一个名为“.tutintro”的特定 div。 ,它位于隐藏的 iframe 内。然后,将其放入我网站上名为“#test”的 div 中。

这是我相信可以让我做到这一点的所有代码,但我似乎无法编辑它以将 div 内容放到我的页面上。

HTML:

<iframe style="display:none;" id="iframe" scrolling="no" src="http://www.w3schools.com/js/" style="border: 0px none; margin-left: -295px; height: 450px; margin-top: -120px; width: 1300px;"></iframe>

<div id="test"></div>

Javascript:

var iframe = document.getElementById('#iframe');
var innerDoc = iframe.contentDocument || iframe.contentWindow.document;
var text = .innerDoc.getElementById('.tutintro');
var output = document.getElementById('test');

output.innerHTML = text;

最佳答案

先生,您无法处理 IFram 的内容(浏览器安全)检查this

关于javascript - 尝试从 iframe 中获取 div,然后将其放入我自己网站上的 div 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20668637/

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