js獲取當(dāng)前頁面路徑示例講解
設(shè)置或獲取對象指定的“文件名”或路徑。
<script>
alert(window.location.pathname)
</script>
設(shè)置或獲取整個 URL 為字符串。
<script>
alert(window.location.href);
</script>
設(shè)置或獲取與 URL 關(guān)聯(lián)的端口號碼。
<script>
alert(window.location.port)
</script>
設(shè)置或獲取 URL 的協(xié)議部分。
<script>
alert(window.location.protocol)
</script>
設(shè)置或獲取 href 屬性中在井號“#”后面的分段。
<script>
alert(window.location.hash)
</script>
設(shè)置或獲取 location 或 URL 的 hostname 和 port 號碼。
<script>
alert(window.location.host)
</script>
設(shè)置或獲取 href 屬性中跟在問號后面的部分。
<script>
alert(window.location.search)
</script>
網(wǎng)頁刷新推薦-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">
相關(guān)文章
JS在可編輯的div中的光標(biāo)位置插入內(nèi)容的方法
這篇文章主要介紹了JS在可編輯的div中的光標(biāo)位置插入內(nèi)容的方法,分別用js與jQuery兩種方式加以實現(xiàn),是非常實用的特效技巧,需要的朋友可以參考下2014-11-11
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ù)進(jìn)行分組是非常常見的功能,不論是實際工作中,還是在面試的場景中應(yīng)用十分廣泛,尤其在函數(shù)式編程中?groupBy?十分常見,下面我們就來學(xué)習(xí)一下groupBy的用法吧2023-12-12
element-ui組件中input等的change事件中傳遞自定義參數(shù)
這篇文章主要介紹了element-ui組件中的input等的change事件中傳遞自定義參數(shù)的實例代碼,本文通過實例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價值 ,需要的朋友可以參考下2019-05-05
JavaScript中的幾個關(guān)鍵概念的理解-原型鏈的構(gòu)建
JavaScript中的prototype,標(biāo)準(zhǔn)翻譯為“原型”,表示對象的初始形態(tài)2011-05-05
利用JavaScript實現(xiàn)春節(jié)倒計時效果(移動端和PC端)
這篇文章主要介紹了通過Html+Css+js如何實現(xiàn)春節(jié)倒計時效果,本文同時介紹了移動端和PC端兩種效果,感興趣的同學(xué)可以跟隨小編一起動手試試2022-01-01

