js中window和location、document

本文介绍了JavaScript中的Location和Document对象,包括Location对象的属性、方法和其在浏览器中的作用,以及Document对象的集合、属性和方法,展示了如何通过这些对象操作和访问HTML文档。
摘要由CSDN通过智能技术生成

代码把te2.html放到tomcat里,网络访问一下试试:

访问地址:http://localhost:8080/testjs/te2.html?ku=yourname&ka=yourage

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" content="免费">
    <!-- <meta http-equiv="refresh" content="3"> -->
    <title>打开</title>

</head>

<body>
    <h3 id="idShow">显示</h3>
    <p id="idContent">内容</p>
    <script type="text/javascript">
        function popAlert() {
            let x;
            let r = window.confirm("你好啊,测试确定");
            if (r === true) {
                x = "按下了\n确定按钮";
            } else {
                x = "按下了\n取消按钮";
            }

            document.getElementById("idShow").innerHTML = x;
        }

        // popAlert();
        let buffer = [];

        buffer.push("href = ".concat(window.location.href).concat("<br>"));
        buffer.push("status = ".concat(window.status).concat("<br>"));
        buffer.push("closed = ".concat(window.closed).concat("<br>"));
        buffer.push("name = ".concat(window.name).concat("<br>"));
        buffer.push("location.host = ".concat(window.location.host).concat("<br>"));
        buffer.push("location.hostname = ".concat(window.location.hostname).concat("<br>"));
        buffer.push("location.pathname = ".concat(window.location.pathname).concat("<br>"));
        buffer.push("location.port = ".concat(window.location.port).concat("<br>"));
        buffer.push("location.protocal = ".concat(window.location.protocal).concat("<br>"));
        buffer.push("location.search = ".concat(window.location.search).concat("<br>"));
        buf
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值