ddrjm ddrjm - 3 months ago 7x
jQuery Question

Force scroll on a specific url

I am trying to achieve an effect/redirect on a website I'm developing for my company.

Previously we have had a

, direct to a specific page showing the weather. Now, since we moved the weather to a section of the root page (
), we want the users who go to
to land on the root page but with the window scrolled to the weather section.

Essentially, i'm trying to achieve the same effect of a same page anchor (
) but with a url.

I've searched on Google for same page anchor url slash but I only could find stuff regarding the regular anchors.

Any help would be appreciated.


I managed to get the desired result using a combination of the answer above and window.pathname essentially:

$(window).load(function() {
    if(window.pathname == '/weather') {
      $('html, body').animate({
          scrollTop: $('#weather-area').offset().top
      }, 3000);