js獲取當前頁面路徑示例講解
設置或獲取對象指定的“文件名”或路徑。
<script>
alert(window.location.pathname)
</script>
設置或獲取整個 URL 為字符串。
<script>
alert(window.location.href);
</script>
設置或獲取與 URL 關聯(lián)的端口號碼。
<script>
alert(window.location.port)
</script>
設置或獲取 URL 的協(xié)議部分。
<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">
相關文章
JavaScript中訪問節(jié)點對象的方法有哪些如何使用
js訪問節(jié)點對象的方法有很多,比如getElementById在本文將舉例為大家介紹下2013-09-09
layui 實現(xiàn)自動選擇radio單選框(checked)的方法
今天小編就為大家分享一篇layui 實現(xiàn)自動選擇radio單選框(checked)的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-09-09
JavaScript中常用數(shù)據(jù)處理函數(shù)groupBy的用法詳解
數(shù)據(jù)處理與分析中,對數(shù)據(jù)進行分組是非常常見的功能,不論是實際工作中,還是在面試的場景中應用十分廣泛,尤其在函數(shù)式編程中?groupBy?十分常見,下面我們就來學習一下groupBy的用法吧2023-12-12
element-ui組件中input等的change事件中傳遞自定義參數(shù)
這篇文章主要介紹了element-ui組件中的input等的change事件中傳遞自定義參數(shù)的實例代碼,本文通過實例代碼給大家介紹的非常詳細,具有一定的參考借鑒價值 ,需要的朋友可以參考下2019-05-05
利用JavaScript實現(xiàn)春節(jié)倒計時效果(移動端和PC端)
這篇文章主要介紹了通過Html+Css+js如何實現(xiàn)春節(jié)倒計時效果,本文同時介紹了移動端和PC端兩種效果,感興趣的同學可以跟隨小編一起動手試試2022-01-01

