现在的位置: 首页 > 综合 > 正文

HTML DOM pathname 属性

2013年11月22日 ⁄ 综合 ⁄ 共 325字 ⁄ 字号 评论关闭
文章目录

HTML DOM pathname 属性

HTML DOM Location 对象参考手册

定义和用法

pathname 属性是一个可读可写的字符串,可设置或返回当前 URL 的路径部分。

语法

location.pathname=path

实例

假设当前的 URL 是: http://example.com:1234/test/test.htm#part2:

<html>
<body>

<script type="text/javascript">
document.write(location.pathname);
</script>

</body>
</html>

输出:

/test/test.htm

TIY

使用 location 对象的 pathname 属性

HTML DOM Location 对象参考手册

抱歉!评论已关闭.