问题描述:

I'm trying to have the homepage of a website automatically load at a specific <div> ID (i.e. www.thesite.com/#bottom), so that there will be content to scroll upwards to.

I tried setting a 301 redirect or use mod.rewrite via .htaccess, but that resulted in too many redirects since it goes to the same page.

Adding some code to the body tag <body onload="window.location.hash = 'bottom'"> works out but it briefly displays the top of the page so there is a sort of delay and bounce that I'm hoping to avoid.

If anyone has a solution to this using .htaccess or JavaScript that they could suggest I would really appreciate it.

网友答案:

Try doing a body onload....

I'm doing the same type of website and that worked for me. Note the different of .href and not .hash, it doesn't seem to skip or jump for me and it's a 20MB site with images / js / css.

相关阅读:
Top