js获取当前页面路径示例讲解
设置或获取对象指定的“文件名”或路径。
<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=刷新 onclick="history.go(0)">
<input type=button value=刷新 onclick="location.reload()">
<input type=button value=刷新 onclick="location=location">
<input type=button value=刷新 onclick="location.assign(location)">
<input type=button value=刷新 onclick="document.execCommand('Refresh')">
<input type=button value=刷新 onclick="window.navigate(location)">
<input type=button value=刷新 onclick="location.replace(location)">
<input type=button value=刷新 onclick="document.URL=location.href">
相关文章
layui 实现自动选择radio单选框(checked)的方法
今天小编就为大家分享一篇layui 实现自动选择radio单选框(checked)的方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧2019-09-09
JavaScript中常用数据处理函数groupBy的用法详解
数据处理与分析中,对数据进行分组是非常常见的功能,不论是实际工作中,还是在面试的场景中应用十分广泛,尤其在函数式编程中 groupBy 十分常见,下面我们就来学习一下groupBy的用法吧2023-12-12
element-ui组件中input等的change事件中传递自定义参数
这篇文章主要介绍了element-ui组件中的input等的change事件中传递自定义参数的实例代码,本文通过实例代码给大家介绍的非常详细,具有一定的参考借鉴价值 ,需要的朋友可以参考下2019-05-05
利用JavaScript实现春节倒计时效果(移动端和PC端)
这篇文章主要介绍了通过Html+Css+js如何实现春节倒计时效果,本文同时介绍了移动端和PC端两种效果,感兴趣的同学可以跟随小编一起动手试试2022-01-01


最新评论