开发者

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=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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜