1. 程式人生 > >location 位置

location 位置

sign click utf col 當前 ati www 端口 文件

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<button type="button" onclick="newDoc()">加載新文檔</button>
<br />
<body>
<script>
document.write(‘輸出當前位置的路徑:‘);
document.write(location.href);
document.write(‘</br>‘);
document.write(‘輸出當前位置的端口:‘);
document.write(location.port);
document.write(‘</br>‘);
document.write(‘輸出當前位置的協議:‘);
document.write(location.protocol);
document.write(‘</br>‘);
document.write(‘輸出web主機的域名:‘);
document.write(location.hostname);
document.write(‘</br>‘);
document.write(‘返回單前頁面的路徑和文件名:‘);
document.write(location.pathname);
document.write(‘</br>‘);
function newDoc(){
document.location.assign(‘http://www.zhaocom.xyz‘);
}
</script>
</body>
</html>

location 位置