Javascript Location测试

w3schools : The Location Object

<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <title>location相关测试</title>
    <style>
        #J_Location {
            line-height: 2.35em;
            font-size: .875em;
        }
    </style>
</head>

<body>
    <div id="J_Location"></div>

    <script>
        var alertStr = 'location   :    ' + location + '<br>' +
            'location.pathname   :    ' + location.pathname + '<br>' +
            'location.host   :    ' + location.host + '<br>' +
            'location.hostname   :    ' + location.hostname + '<br>' +
            'document.URL   :    ' + document.URL + '<br>' +
            'location.href   :    ' + location.href + '<br>' +
            'location.protocol   :    ' + location.protocol + '<br>' +
            'location.origin   :    ' + location.origin + '<br>' +
            'location.search   :    ' + location.search + '<br>' +
            'location.hash   :    ' + location.hash

        //hash -Sets or returns the anchor portion of a URL.
        //host -Sets or returns the hostname and port of a URL.
        //hostname -Sets or returns the hostname of a URL.
        //href -Sets or returns the entire URL.
        //pathname -Sets or returns the path name of a URL.
        //port -Sets or returns the port number the server uses for a URL.
        //protocol -Sets or returns the protocol of a URL.
        //search -Sets or returns the query portion of a URL

        //hash 设置或返回从井号 (#) 开始的 URL(锚)。
        //host 设置或返回主机名和当前 URL 的端口号。
        //hostname 设置或返回当前 URL 的主机名。
        //href 设置或返回完整的 URL。
        //pathname 设置或返回当前 URL 的路径部分。
        //port 设置或返回当前 URL 的端口号。protocol 设置或返回当前 URL 的协议。
        //search 设置或返回从问号 (?) 开始的URL(查询部分) 。

        document.getElementById('J_Location').innerHTML = alertStr;
    </script>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值