jquery - Javascript not adding id in address bar -
for reason javascript not add id of clicked element address bar. else correctly.
here jsfiddle: http://jsfiddle.net/4x7la64s/
so example if click on #introduction
want put id in address bar so: example.com/page.php/#introduction
based in code, after doing:
e.preventdefault();
you like:
var hash = jquery(this).attr("href"); //your clicked link if (window.history && window.history.pushstate) { history.pushstate(null, null, 'hash'); // won't make page jump id } else { location.hash = hash; //this fallback old browsers , make page jump id }
Comments
Post a Comment