Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I turn a string into a Location object? [duplicate]

Possible Duplicate:
Creating a new Location object in javascript

If the user inputs a string that is a URL, what's the easiest way to turn it into a Location object (like window.location) so I can use methods and properties like obj.hostname?

like image 906
Kerrick Avatar asked Jul 18 '11 17:07

Kerrick


1 Answers

Don't know if you can create a Location object, but this article explains how to use an anchor tag for the same effect:

http://james.padolsey.com/javascript/parsing-urls-with-the-dom/

like image 101
jimbo Avatar answered Nov 17 '22 12:11

jimbo