I\'m trying to update the URL using window.location.hash or history.pushState.
window.location.hash
history.pushState
What are the differences and advantages of each method?
history.pushState is better than location.hash. but it is a HTML5 feature. so always better to have a fallback method like below.
location.hash
if (typeof(window.history.pushState) == 'function') { window.history.pushState(null, path, path); } else { window.location.hash = '#!' + path; }