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

吃可爱长大的小学妹 提交于 2019-12-30 18:29:20

问题


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?


回答1:


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/



来源:https://stackoverflow.com/questions/6736595/how-can-i-turn-a-string-into-a-location-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!