3

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.

Whymarrh
  • 13,139
  • 14
  • 57
  • 108
  • just don't do it onload, do it inline and you won't see the dealy – dandavis Jun 25 '14 at 19:37
  • placed this in the head which seems to work fine in chrome and safari, but firefox stays anchored to the top of the page. Here is the url where I'm trying to make this happen [link](http://www.freekaratedesign.com/thepeakbeer/) – user2984530 Jun 26 '14 at 15:19
  • make sure the script appears after the section you are jumping to, which must be down more from the head... – dandavis Jun 26 '14 at 18:06
  • brilliant thanks so much for taking the time, switched to .href as Earle suggested and placed below section and working exactly how I had hoped. – user2984530 Jun 26 '14 at 21:30
  • possible duplicate of [.htaccess redirect with fragment](http://stackoverflow.com/questions/371791/htaccess-redirect-with-fragment) – Whymarrh Jul 30 '14 at 03:37

1 Answers1

0

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.

Earle
  • 1