- document.location
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<b>document.location使用举例 </b ><p>
<script type ="text/javascript">
document.write( " 当前位置: " + document.location + " <p> " );
document.write( " 当前位置的url路径: " + document.location.pathname + " <p> " );
document.write( " 当前位置的url协议: " + document.location.protocol + " <p> " );
document.write( " 当前位置的url端口: " + document.location.port + " <p> " );
// 设置新的location
document.location.href= " http://www.baidu.com " ; //直接跳转的
// window.open('http://www.baidu.com');
</script>
```