开发者

To get path name with url values in jquery

开发者 https://www.devze.com 2023-01-28 17:15 出处:网络
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=2

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=2
I 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/

0

精彩评论

暂无评论...
验证码 换一张
取 消