【发布时间】:2016-05-02 23:59:07
【问题描述】:
我创建了两个网页,一个在 iframe 中包含另一个。我想通过javascript从父页面滚动嵌入页面。
到目前为止我所尝试的:
$('#go').scrollTop(200);$('.footer').scrollTop(200);var frame = document.getElementById('go');
frame.contentWindow.scrollTo(0, 200);
这些都不起作用
父网页html:
<html>
<body>
.
.
.
<div class="footer">
<iframe id="go" src="go.html"></iframe>
</div>
</body>
</html>
这两个网页都是计算机上的本地文件,我正在使用带有“--allow-file-access-from-files”标志的 Google chrome。
如何将 iframe 滚动到某个位置?
【问题讨论】:
-
你知道“go.html”的内容吗?您可以简单地关注其中的必需元素吗?
-
@YuriyGalanter 我知道 go.html 的内容,但它包含另一个域上的另一个 iframe,所以我无法访问它。我在 iframe 中做了 iframe 以绕过相同的来源政策。
标签: javascript jquery