3

This is an example URL.

http://stackoverflow.com/questions/ask?a=1&b=2

question: I need to fetch path name along with url values like this

/questions/ask?a=1&b=2
I need jquery or javascript solution

1 Answer 1

3
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/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.