通过JavaScript获取到导航条中的HTTP信息

  • style中带有注释的部分为获取HTTP中的信息

  • body中显示效果为:

    • 打开页面是自动弹出输入提示框
    • 点击删除时,会有警告框弹出
      • 点击确定时,删除信息
      • 点击取消时,不删除信息
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <title></title>

    <!-- JavaScript代码 -->
    <script>
        //        console.log("URL地址: " + window.location.href);
        //        console.log("主机名: " + window.location.hostname);
        //        console.log("端口: " + window.location.port);
        //        console.log("主机: " + location.host); // 主机名+端口
        //        console.log("协议: " + location.protocol);
        //        console.log("路径: " + location.pathname);

        //        console.log("有效的宽度(单位:像素): " + screen.availWidth);
        //        console.log("有效的高度(单位:像素): " + screen.availHeight);
        //        console.log("每个像素颜色的位数: " + screen.colorDepth);

        //        document.write("官方浏览器代码名的字符串的表示:" + navigator.appCodeName + "<br/>");
        //        document.write("官方浏览器名的字符串的表示:" + navigator.appName + "<br/>");
        //        document.write("用户代理:" + window.navigator.userAgent + "<br/>");
        //        document.write("版本信息:" + window.navigator.appVersion + "<br/>");
        //        document.write("浏览器所在的计算机的平台:" + window.navigator.platform + "<br/>");
        //        document.write("Cookie:" + window.navigator.cookieEnabled + "<br/>");
    </script>
</head>
<body>
<script>
    function remove() {
        var r = confirm("确定要删除吗?");
        console.log(r);
    }

    prompt("您几岁?");
</script>
<table>
    <tr>
        <th>姓名</th>
        <th>年龄</th>
        <th>操作</th>
    </tr>
    <tr>
        <td>张三</td>
        <td>19</td>
        <td><input type="button" value="删除" onclick="return remove();"/></td>
    </tr>
    <tr>
        <td>李四</td>
        <td>18</td>
        <td><input type="button" value="删除" onclick="return remove();"/></td>
    </tr>
    <tr>
        <td>王五</td>
        <td>20</td>
        <td><input type="button" value="删除" onclick="return remove();"/></td>
    </tr>
    <tr style="display: none">
        <td>赵六</td>
        <td>21</td>
        <td><input type="button" value="删除" onclick="return remove();"/></td>
    </tr>
    <tr>
        <td>孙七</td>
        <td>20</td>
        <td><input type="button" value="删除" onclick="return remove();"/></td>
    </tr>
</table>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值