2 Star 34 Fork 17

阿基米东/Web_Learning

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
index.html 1.56 KB
一键复制 编辑 原始数据 按行查看 历史
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Get Server IP</title>
</head>
<body>
<script>
window.onload = function print() {
document.write("Get Http server IP address");
// 1. 设置或获取对象指定的文件名或路径
console.log(window.location.pathname);
// 2. 设置或获取整个 URL 为字符串
console.log(window.location.href);
// 3. 设置或获取与 URL 关联的端口号码
console.log(window.location.port);
// 4. 设置或获取 URL 的协议部分
console.log(window.location.protocol);
// 5. 设置或获取 href 属性中在井号“#”后面的分段
console.log(window.location.hash);
// 6. 设置或获取 location 或 URL 的 hostname 和 port 号码
console.log(window.location.host);
// 7. 设置或获取 href 属性中跟在问号后面的部分
console.log(window.location.search);
// 8. 获取变量的值(截取等号后面的部分)
var url = window.location.search;
console.log(url);
// 9. 用来得到当前网页的域名
var domain = document.domain;
console.log(domain);
// 10. WebSocket
console.log("ws://" + window.location.host + "/ws");
}
</script>
</body>
</html>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/luhuadong/Web_Learning.git
git@gitee.com:luhuadong/Web_Learning.git
luhuadong
Web_Learning
Web_Learning
master

搜索帮助