I have the following url :
http://localhost/get/this/url/in/a-nice-format.html
var pagename= location.pathname.split('/').join(':');
gives me
:get:this:url:in:a-nice-format.html
How do I get rid of the first ":"?
Thanks.
I have the following url :
http://localhost/get/this/url/in/a-nice-format.html
var pagename= location.pathname.split('/').join(':');
gives me
:get:this:url:in:a-nice-format.html
How do I get rid of the first ":"?
Thanks.
pagename = location.pathname.split('/').join(':').substr(1);
Hi you can use substrings method. Simply do this.... var pageName2 = pageName.substring(1); I hope this helps.
I'm not able to comment yet but waned to help anyway. And there's probably an answer somewhere else...
Anyway, try using slice() and passing in a 'begin' argument of 1 to remove the first ':'.
Like this: var pagename= location.pathname.split('/').join(':').slice(1);