zoukankan      html  css  js  c++  java
  • location对象属性

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>location对象属性</title>
        <!-- 
            host        设置或返回主机名和当前 URL 的端口号。
            hash        设置或返回从井号 (#) 开始的 URL(锚)。
            href        设置或返回完整的 URL。
            hostname    设置或返回当前 URL 的主机名。
            port        设置或返回当前 URL 的端口号。
            pathname    设置或返回当前 URL 的路径部分。
            search        设置或返回从问号 (?) 开始的 URL(查询部分)。
            protocol    设置或返回当前 URL 的协议。
         -->
    </head>
    <body>
        <input type="button" id="inp" value="点击">
        <script>
            console.log(location.host);//主机名和端口号
            console.log(location.hash="#inp");//锚(#)后面的url
            console.log(location.href);//完整url
            console.log(location.hostname);//主机名
            console.log(location.port);//端口号
            console.log(location.pathname);//url的路径部分
            console.log(location.search="?id=10");//问号(?)后面的url
            console.log(location.protocol);//url协议
        </script>
    </body>
    </html>
  • 相关阅读:
    【SCOI2012】滑雪
    【NOI2008】假面舞会
    ※初赛知识总结※
    【FJSC2012】足球
    【中山市选2011】杀人游戏
    【SDOI2008】洞穴勘测
    【SNOI2017】炸弹
    【LGOJ1606】白银莲花池
    int类型中为什么负数比正数多了一个数?
    utf8、utf16、utf32之间的格式
  • 原文地址:https://www.cnblogs.com/vinson-blog/p/12077422.html
Copyright © 2011-2022 走看看