【发布时间】:2020-07-17 07:01:01
【问题描述】:
我正在尝试将数据从 eBay 提取到 iframe。问题是它没有调整其内容的高度,并在下面留下很大的间隙。我尝试采用 iframe Body 的 offsetHeight,但由于它是 CROSS-DOMAIN,我无法从中提取任何属性。请让我知道是否有任何方法可以通过 JS 甚至 CSS 来实现。 我已经尝试了所有可以从 StackOverflow 找到的方法,但它似乎不适用于这里。
<script>
function onLoad() {
console.log(
"height",
document.getElementById("target").contentWindow.document.body.offsetHeight
);
}
</script>
<div class="test">
<iframe
id="target"
sandbox="allow-scripts allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-top-navigation"
onload="onLoad()"
class="iframe"
frameborder="0"
height="auto"
width="100%"
src="https://vi.vipr.ebaydesc.com/ws/eBayISAPI.dll?ViewItemDescV4&item=383383822672&t=0&tid=310&category=171228&seller=walrus_0&excSoj=1&excTrk=1&lsite=3&ittenable=false&domain=ebay.co.uk&descgauge=1&cspheader=1&oneClk=2&secureDesc=1"
title="Sellers description of item"
></iframe>
</div>
【问题讨论】:
-
没有办法从父窗口知道任何关于 iframe 内容的信息,除非您可以访问孩子的代码,在这种情况下,您可以关注 stackoverflow.com/questions/9153445/…
-
我无权访问来自 eBay 的子元素
-
那你不能做你要求的事情
-
我已经尝试了上面的那些,但我无权在子元素中添加任何东西
标签: javascript html css iframe