javascript - How do I return part of the url using window.location.hash -


i stuck

i using code below add name of dynamically loaded page url

var value = $(this).attr('href');      e.preventdefault();     window.location.hash = value; 

it works returning in url

http://www.sitename.com/dev888/#http://www.sitename.com/dev888/page-name

but want part of url return example below

http://www.sitename.com/dev888/#/page-name

how can edit code above desired result?

thank!!

you can play value last 1

var value = $(this).attr('href');      e.preventdefault();     var parts = value.split("/");     value = parts[parts.length-1];      window.location.hash = value; 

or can change attr('href') value want directly :)

i hope can

and may want take @ pusstate

https://developer.mozilla.org/en-us/docs/web/guide/dom/manipulating_the_browser_history


Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -