I want to change URL of the site when i scrolling the page. When I scrolling the page,URL of the page will automatically change after each content.
- 
                    what have you tried so far share some code. And use `.scroll()` jquery event with `#` values. – valar morghulis Apr 27 '15 at 09:29
- 
                    1Look here: http://stackoverflow.com/questions/3338642/updating-address-bar-with-new-url-without-hash-or-reloading-the-page – ufocoder Apr 27 '15 at 09:29
1 Answers
There are two parts to this:
- Detecting scrolling and entering sections - You do this by using the - scrollevent on- window, and then comparing the- scrollTopto the position of the section(s) you want to compare to.
- Changing the URL - You have a few choices here: - You can set the hash fragment (the - #xyzpart of the URL) by assigning to- location.hash. Doing that will create a history entry, though, so I don't recommend it. (If just scrolling a page added a bunch of entries to my browsing history, I wouldn't be a happy user.)
- You can use - location.replace(newUrl)using the current URL updated with a new hash, which won't create a history entry.
- You can use - history.pushStatewith any (reasonable) URL you want in modern browsers. Again that will create a history entry.
- You can use - history.replaceStatewith any (reasonable) URL you want in modern browsers, which won't create a history entry.
 - More about the - historyAPI on MDN.
 
    
    - 1,031,962
- 187
- 1,923
- 1,875
