location对象

    xiaoxiao2025-07-08  15

    //设置页面跳转地址 location.herf = "地址"; //与上等同 location.assign("地址"); //重新加载--刷新 location.reload(); //设置页面加载记录----但因为没有历史纪录,所以页面跳转后不能返回 location.replace("地址"); //地址栏#及后面的内容 console.log(window.location.hash); //主机名及端口号 console.log(window.location.host); //主机名 console.log(window.location.hostname); //文件的路径---相对路径 console.log(window.location.pathname); //端口号 console.log(window.location.port); //协议 console.log(window.location.protocol); //搜索内容 console.log(window.location.search);
    最新回复(0)