<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Get IP Address</title>
<script>
function displayURL() {
var url = window.location.href; // 获取当前URL
document.getElementById("currentUrl").textContent = url; // 显示在HTML中
var hostname = window.location.hostname;// 获取当前ip
document.getElementById("currentIp").textContent = hostname; // 显示在HTML中
var port = window.location.port;// 获取当前端口
document.getElementById("currentPort").textContent = port; // 显示在HTML中
var host = window.location.host;//当前访问的IP和端口
document.getElementById("currentIphost").textContent = host; // 显示在HTML中
}
</script>
</head>
<body οnlοad="displayURL();">
<p>当前访问的URL是:<span id="currentUrl"></span></p>
<p>当前访问的IP是:<span id="currentIp"></span></p>
<p>当前访问的端口是:<span id="currentPort"></span></p>
<p>当前访问的IP和端口是:<span id="currentIphost"></span></p>
</body>
</html>