开发者

Using Scroll by for mobile devices

I have a site that I'm building a mobile version for. I would like to be able to scroll the page down a bit when the page loads so I can hide the address section at the top of the page. I'm used to using window.scrollBy to move the page around, but it doesn't seem to work correctly on the mobile version.

<script type="text/javascript">
    $(document).ready(fu开发者_如何学运维nction() {
        window.scrollBy(0,25);
    });
</script>

I had put an alert after the window.scrollBy and when it goes off it does move correctly, but when it is finished loading the page moves back to the default starting point.

m.engadget.com shows an example of what I want to have happen. Any ideas on how to replicate something like that? I'm using javascript, jquery and php.


Well since you only need to scroll once (when the page is loaded) I think you can use: window.scrollTo(xpos, ypos) method, rather than scrollby, maybe this fixes the problem?

If not, than jquery is probably calling a method after you, which say something like: scrollto(0,0), to be sure that the page is showing from the top, it would be strange.. because you tell to do your method at document ready, which is the latest stage i think. If this is the case, it would be easier if you tell us the url of the site, we could watch the source code, maybe 2 things conflicts with each other.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜