<!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>