$(document).ready(function() { // Find the correct topic var value = window.location.href.substring(window.location.href.lastIndexOf('/') + 1); if (value) { scrollTo(value); } }); //Scroll to the element function scrollTo(hash) { var tag = $(hash)[0]; tag.scrollIntoView(); }