手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >js获取当前页面路径示例讲解
js获取当前页面路径示例讲解
摘要:设置或获取对象指定的“文件名”或路径。alert(window.location.pathname)设置或获取整个URL为字符串。alert...

设置或获取对象指定的“文件名”或路径。

<script>

alert(window.location.pathname)

</script>

设置或获取整个 URL 为字符串。

<script>

alert(window.location.href);

</script>

设置或获取与 URL 关联的端口号码。

<script>

alert(window.location.port)

</script>

设置或获取 URL 的协议部分。

<script>

alert(window.location.protocol)

</script>

设置或获取 href 属性中在井号“#”后面的分段。

<script>

alert(window.location.hash)

</script>

设置或获取 location 或 URL 的 hostname 和 port 号码。

<script>

alert(window.location.host)

</script>

设置或获取 href 属性中跟在问号后面的部分。

<script>

alert(window.location.search)

</script>

网页刷新推荐-JS

<input type=button value=刷新>

<input type=button value=刷新>

<input type=button value=刷新>

<input type=button value=刷新>

<input type=button value=刷新>

<input type=button value=刷新>

<input type=button value=刷新>

<input type=button value=刷新>

【js获取当前页面路径示例讲解】相关文章:

JQuery选择器、过滤器大整理

jQuery获取页面元素绝对与相对位置的方法

js获取变量

jQuery实现自动滚动到页面顶端的方法

JavaScript获取当前运行脚本文件所在目录的方法

Node.js 条形码识别程序构建思路详解

微信jssdk在iframe页面失效问题的解决措施

获得当前页面URL地址的三个JS代码

JS获取时间的相关函数及时间戳与时间日期之间的转换

超酷右下浮出广告窗口代码

精品推荐
分类导航