代码示例:(标识:eg_js_location_pathname)
<!DOCTYPE html>
<html>
<body>

<h1>window.location 对象</h1>

<p id="demo"></p>

<script>
document.getElementById("demo").innerHTML =
"页面路径是:" + window.location.pathname;
</script>

</body>
</html>
运行结果: