html - Getting the part of string from the URL using jQuery? -
this question has answer here:
- how parse url hostname , path in javascript? 20 answers
i have following url in browser address bar
http://localhost:8080/myapp/myscreen?username=ccc
i need part /myscreen?username=ccc
it, excluding root.
how can using jquery?
var = location.pathname + location.search
if reason want hash (the #
part of url), use instead:
var = location.pathname + location.search + location.hash
then, must remove app root path a
:
a = a.replace( "/myapp/", "" ); // or = a.substring( "/myapp/".length );
Comments
Post a Comment