首页 > 代码库 > JS获取链接中域名等信息

JS获取链接中域名等信息

以访问百度为例子http://pan.baidu.com/share/qrcode?w=150&h=150&url=http%3A%2F%2F172.16.1.96%2FWeb%2FGetUserOrdersInfo%3Ftelephone%3D18814129365%26reserveID%3D21

获取链接中的域名等信息:window.location.(xxx)

其中(xxx)可以是一下内容:

hash: ""
host: "pan.baidu.com"
hostname: "pan.baidu.com"
href: "http://pan.baidu.com/share/qrcode?w=150&h=150&url=http%3A%2F%2F172.16.1.96%2FWeb%2FGetUserOrdersInfo%3Ftelephone%3D18814129365%26reserveID%3D21"
origin: "http://pan.baidu.com"
pathname: "/share/qrcode"
port: ""
protocol: "http:"

search: "?w=150&h=150&url=http%3A%2F%2F172.16.1.96%2FWeb%2FGetUserOrdersInfo%3Ftelephone%3D18814129365%26reserveID%3D21"

 

JS获取链接中域名等信息