title: Run javascript autoscroll function after page full load
body: <p>I have a functionality on a page that should auto-scroll by javascript when a url matches:</p>
  
  <pre><code>$(window).load(function () {
          if (window.location.href.indexOf("something-on-url") &gt; -1) {
                  $("html,body").animate({
                      scrollTop: $("#specificDiv").offset().top
                  }, 300);
          }
  </code></pre>
  
  <p>The problem is that I have a carousel of images at the top of the page, and it takes a while until its loaded, so it makes the autoscroll before the carousel is there (the carousel height is not taken into count so it's autoscrolling as many pixels as it should minus the carousel height). </p>
  
  <p>I've tried <code>document.ready()</code> instead of <code>$(window).load</code>, same result. I've tried adding the picture/carousel height, but if I go <code>img.height()</code>, it will give me "0" at that time, and hardcoded it it's not an option since this is a mobile responsive site. I've also tried using <code>.onload()</code> to the img tag in the carousel and on the carousel tags, but this just doesn't trigger the autoscroll (never).</p>
  
  <p>Only thing working so far, it's delay the scroll function with a <code>setTimeOut()</code>, but depending on the user it may load the carousel slower, so a safe <code>setTimeOut()</code> will be to long for most cases.</p>