首页 文章

Javascript - 当iFrame SRC发生变化时,将DIV滚动条移至顶部

提问于
浏览
0

回复:http://www.gooplusplus.com/cost-of-living-compare-cities/

我创建了一个相对简单的网站,以便更容易地比较潜在的“外派”城市 . 每个城市都有生活成本数据,维基百科,外籍博客,气候信息和谷歌 Map 的链接(目标= iframe) .

左栏包含每个城市的几个控制链接 .

主窗口是单个 iframe within a DIV . Iframe滚动设置为OFF . Scrolling is done using the iframe's DIV. iframe内容来自 external domains .

problem: 如果向下滚动以查看长维基百科条目,然后用户点击新的城市链接 iframe content position stays at the old DIV position ,这不是通常想要的 .

期望的行为( Javascript ,而不是jQuery):

Move the DIV's vertical scrollbar - go to the TOP of document whenever the iframe SRC document changes.

enter image description here

1 回答

  • 1

    这实际上比使用iframe的更复杂的网站容易得多 . 对于这个简单的网页,BODY而不是DIV控制滚动 .

    <iframe src="numbeo.html" onLoad="window.scrollTo(0,0);" etc. >
    

相关问题