GoFuture's Blogs

为自己加油,努力啦,木头人。。。。。 我就是我,因为努力而独一无二的我!!!

 

js的url取值

例如地址: http://www.juuyou.com:8080/test.html?aaa=bbb#dddd
如果要取得域名,一般人应该会去通过indexof(),split(),substring()等方法处理。但有更简单的。

下面说下怎么获取和获取的值为什么:

document.location.protocol — http:
document.location.hostname — www.juuyou.com
document.location.host — www.juuyou.com
document.location.port — :8080
document.location.pathname — /test.html
document.location.hash — #dddd
document.location.search — ?aaa=bbb

 

摘抄地址 http://www.juuyou.com/?p=42&cpage=1 

posted on 2011-04-20 14:50  GoFuture  阅读(702)  评论(1)    收藏  举报

导航