javascript - detect page jump to a specific element ID -


A user reloads the page after a certain action, and it adds a #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

What would I do that instead of jumping to the right of jQuery using jQuery and then to the right of the #someId element it jumped up to 100px and a smooth scroll

Is this possible?

"post-text" itemprop = "text">

This is a hash change event of the 'window' document object that you absolutely need to catch this behavior You can use:

  1. Javascript solution:

      window.addEventListener ('hash change', function) (// smooth scroll code) ); JQuery Solution (v1.8 +):  
      jQuery (window) .on ('hashchange', function () {// smooth scroll code});     

    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.

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -