In JavaScript, is there any class equivalent for
- NSURL class in iOS SDK or
- URL class in Java?
With such class, I want to:
- normalize URL,
- compose a URL from scheme, host, path components, etc…, and
- decompose a URL into its elements.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
James Padolsey had tackled this problem.
In a nutshell, you can create an anchor element using
document.createElement(), and several of its native properties are then easily accessible, such asprotocol,port, andhostname.For more information: http://james.padolsey.com/javascript/parsing-urls-with-the-dom/