在iframe中加载远程内容时滚动父页面 [英] Scrolling parent page when remote content loads in iframe

查看:302
本文介绍了在iframe中加载远程内容时滚动父页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在致力于在主页上的iframe中加载远程内容(房地产列表)的网站。问题在于框架非常长,列表页面之间的导航(位于iframe的远程内容中)位于底部。因此,当点击下一个按钮时,下一页加载,但它在内容的底部,因为父页是一个滚动。所以,当我在iframe中加载新内容时,我想要做的就是让父页面跳转到顶部。



我已经做了很多四处看看,但是我发现的所有解决方案似乎都基于iframe中的内容是本地和可访问的假设。我无法访问正在加载的内容 - 完全是第三方。

到该网站的链接是: http://www.rogermcmillan.com.au
如果您点击待售物业标签,滚动到底部,然后点击'下一步',你会发现当新内容加载时页面仍然处于底部。

>

将JavaScript放入< iframe srcStuff onLoad =scrollMeUp();>



< head> 以下代码中:

  function scrollMeUp(){ 
window.scroll(0,0);





$ b如果这不起作用,请尝试使用警报进行调试,检查窗口是指什么是,是iframe还是父母,或者这个函数可能不适用于所有浏览器,但我不确定。


I'm working on a website that loads remote content (real estate property listings) in an iframe on the main page. The issue being that the frames are quite long, and the navigation between pages of listings (located within the remote content of the iframe) sits at the bottom. Hence, when the 'next' button is clicked, the next page loads but it's at the bottom of the content because the parent page is the one scrolling. So what I want to do is make the parent page jump to the top whenever new content is loaded in the iframe.

I've done a lot of looking around, but all the solutions I've found seem to be based on the assumption that the content within the iframe is local and accessible. I haven't got access to the content that is being loaded in my frame — it's entirely third-party.

The link to the website is: http://www.rogermcmillan.com.au If you click on the 'properties for sale' tab, scroll to the bottom, and then click 'next', you'll see that the page remains at the bottom when the new content has loaded.

解决方案

Put javascript like <iframe srcStuff onLoad="scrollMeUp();">

And in <head> following code:

function scrollMeUp() {
    window.scroll(0,0);
}

If that doesn't work try debugging with alert, check what does window refer to, is it iframe or parent, or this function might not work on all browser, but I am not sure about that.

这篇关于在iframe中加载远程内容时滚动父页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆