滚动到页面加载顶部(HTML) [英] Scroll To Top On Page Load (HTML)
问题描述
我已经尝试了onload="window.scrollTo(0,0);"
和onload="$('html,body').scrollTop(0);"
,但是页面加载后它仍然停留在当前位置,我正在使用框架.我尝试了其他一些建议,但是仍然无法有人请我指出正确的方向.我是否需要在框架顶部添加滚动条?当里面的框架重新加载时,我需要包含该框架的页面重新加载,希望这是有道理的.
I have tried both onload="window.scrollTo(0,0);"
and onload="$('html,body').scrollTop(0);"
but after the page loads it still stays at the current position, I am using frames. I have tried some of the other suggestions but still no luck could someone please point me in the right direction. Do I need to add a scroll to top to my frame? I need the page that contains the frame to reload when the frame inside reloads, hope it makes sense.
<body onload="window.scrollTo(0,0); $('html,body').scrollTop(0);">
<iframe id="my-iframe-tag" scrolling="no">
</iframe>
</body>
<body onload="window.scrollTo(0,0); $('html,body').scrollTop(0);">
<iframe id="my-iframe-tag" scrolling="no">
</iframe>
</body>
推荐答案
在进行了一些搜索之后,所有这些似乎已经解决了问题onload="parent.scrollTo(0,0);"
hi all this seems to have done the trick onload="parent.scrollTo(0,0);"
after some searching this helped Scroll to top of parent frame on iframe change? thanks though
这篇关于滚动到页面加载顶部(HTML)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!