To get path name with url values in jquery
This is an example URL.
http://stackoverflow.com/questions/ask?a=1&b=2
question: I ne开发者_StackOverflow社区ed to fetch path name along with url values like this
/questions/ask?a=1&b=2I need jquery or javascript solution
var url = document.createElement('a');
url.href = 'http://stackoverflow.com/questions/ask?a=1&b=2';
alert(url.pathname + url.search);
Demo: http://jsfiddle.net/karim79/8XYYj/
精彩评论