javascript - detect page jump to a specific element ID -
A user reloads the page after a certain action, and it adds a What would I do that instead of jumping to the right of jQuery using jQuery and then to the right of the Is this possible? This is a hash change event of the 'window' document object that you absolutely need to catch this behavior You can use: Javascript solution: Note: hash switch event triggers on the URL hash change (location.hash) Has not triggered hash convertible event going from www.example.com/about.html#first to www.example.com/contact.html#second rather than from a different page. Will be done. #someId The url URL will be
localhost / panel / mypage.php # someId and as a default action, the browser will jump to an element with the ID of
#someId element it jumped up to 100px and a smooth scroll
window.addEventListener ('hash change', function) (// smooth scroll code) ); JQuery Solution (v1.8 +):
jQuery (window) .on ('hashchange', function () {// smooth scroll code});
Comments
Post a Comment