How to have a web page load at the bottom of the s

2019-07-25 13:39发布

问题:

I am creating a reverse site, meaning the opening spot on the page is at the bottom and you scroll up to go through content. a simple command to explain what i mean is http://url.com/#bottom (or #footer). However i want to avoid having to create an "ENTER" site page that lines to #bottom and i cannot use a URL redirect to any #adress.

No im not trying to spoof some free server or something, you can checkout what im trying to do at Sean-holt.com. (note im still in the beginning of the work. but just go to the bottom and then scroll up, I want the site to open at the picture of the world).

I just want the first place the viewer to see is the bottom of the page and then have to scroll up.

How can i accomplish this?

Thanks a lot for your help!!!!! you guys rock!

(P.S. This is the first time i have used stack Overflow!)

回答1:

I think you should do it with Javascript/jQuery instead of redirecting again

Put this in the head tag of your file

<script>
// after dom is loaded
$(function() {
  // scroll all the way down
  $('html, body').scrollTop($(document).height() - $(window).height());
});
</script>


回答2:

<body onload="window.location.hash = 'footer'">

Where the footer has id="footer".



回答3:

This can be useful for you.

http://demos.flesler.com/jquery/scrollTo/

I did not use this but may be useful for you.



回答4:

Dan Lee's idea is great.. Just add or subtract something to achieve your ideal position.
I've done it like this:

<script>
        // after dom is loaded
        $(function() {
          // scroll all the way down
          $('html, body').scrollTop($(document).height() - ($(window).height() + 280));
        });
    </script>