如何将字符串转换为Location对象? [英] How can I turn a string into a Location object?
本文介绍了如何将字符串转换为Location对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Possible Duplicate:
Creating a new Location object in javascript
如果用户输入的字符串是URL,最简单的方法是将其转换为位置对象(如window.location
),因此我可以使用obj.hostname
?
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
?
推荐答案
不知道是否可以创建Location对象,但是本文介绍了如何使用锚标记实现相同的效果:
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/
这篇关于如何将字符串转换为Location对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文