(function(){ var hash = decodeURIComponent((location.href.match(/#(.*)$/) || [])[1]); if(hash){ var el = document.querySelector(hash), t = 0; do { t += el.offsetTop; } while (el.offsetParent && (el = el.offsetParent)); window.scrollTo(0, t); } })();