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

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -