有什么方法可以在 iframe 内建立链接来控制主页。我需要从 iframe 建立一个链接,使主页转到顶部。
例如
<html> <- mainpage
...some arcticle...
<iframe>
...long article...
<a href="goback">Go Back</a>
</iframe>
</html>
点击“返回”后,我需要滚动到主页顶部(不仅仅是 iframe)
我无法在主页内使用“返回顶部”链接,它必须位于 iframe 中。
谢谢:)
最佳答案
您可以使用元素中的id
属性跳转到页面顶部。
<html id="top">
<!-- Some content here -->
<iframe>
<!-- Long Article here -->
<a href="#top">Jump to top</a>
</iframe>
</html>
关于javascript - iframe 中的页面顶部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37479805/