JS location.pathname属性
location.pathname属性
JavaScript window.location对象中的pathname属性,可返回当前页面的路径名,一般是URL地址中主机名之后的那一部分,为一个字符串类型。
语法
window.location.pathname
返回值
JS string类型值。
locaiton.pathname实例代码,及在线编辑器
<script>
var pathname = location.pathname
alert(pathname+" 类型为:"+typeof pathname)
</script>