js獲取當(dāng)前頁面路徑示例講解
設(shè)置或獲取對(duì)象指定的“文件名”或路徑。
<script>
alert(window.location.pathname)
</script>
設(shè)置或獲取整個(gè) URL 為字符串。
<script>
alert(window.location.href);
</script>
設(shè)置或獲取與 URL 關(guān)聯(lián)的端口號(hào)碼。
<script>
alert(window.location.port)
</script>
設(shè)置或獲取 URL 的協(xié)議部分。
<script>
alert(window.location.protocol)
</script>
設(shè)置或獲取 href 屬性中在井號(hào)“#”后面的分段。
<script>
alert(window.location.hash)
</script>
設(shè)置或獲取 location 或 URL 的 hostname 和 port 號(hào)碼。
<script>
alert(window.location.host)
</script>
設(shè)置或獲取 href 屬性中跟在問號(hào)后面的部分。
<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)文章
地址欄傳遞中文參數(shù)亂碼在js里用escape轉(zhuǎn)碼
亂碼,頭大的一件事可以考慮轉(zhuǎn)碼方式不直接傳中文,在js里用escape轉(zhuǎn)碼,具體實(shí)現(xiàn)如下,有類似情況的朋友可以參考下2013-08-08JavaScript版DateAdd和DateDiff函數(shù)代碼
VBScript中有兩個(gè)非常好用的日期操作函數(shù):DateAdd用來給日期添加指定時(shí)間間隔,DateDiff用來返回兩個(gè)日期的時(shí)間間隔??上У氖荍avaScript沒有,不過我們可以寫一個(gè)函數(shù)來實(shí)現(xiàn),一樣的,呵呵2012-03-03javascript檢測(cè)兩個(gè)數(shù)組是否相似
Javascript不能直接用==或者===來判斷兩個(gè)數(shù)組是否相等,無論是相等還是全等都不行,要判斷JS中的兩個(gè)數(shù)組是否相同,需要先將數(shù)組轉(zhuǎn)換為字符串,再作比較。2015-05-05js關(guān)閉當(dāng)前頁面(窗口)的幾種方式總結(jié)
js關(guān)閉當(dāng)前頁面(窗口)的幾種方式總結(jié),需要的朋友可以參考一下2013-03-03JavaScript實(shí)現(xiàn)帶播放列表的音樂播放器實(shí)例分享
這篇文章主要介紹了JavaScript實(shí)現(xiàn)帶播放列表的音樂播放器實(shí)例分享,包括對(duì)播放完歌單之后沒有將要播放的歌曲的提示功能,需要的朋友可以參考下2016-03-03手寫的一個(gè)兼容各種瀏覽器的javascript getStyle函數(shù)(獲取元素的樣式)
這篇文章主要介紹了手寫的一個(gè)兼容各種瀏覽器的javascript getStyle函數(shù),用來取元素的樣式,需要的朋友可以參考下2014-06-06微信小程序網(wǎng)絡(luò)請(qǐng)求實(shí)現(xiàn)過程解析
這篇文章主要介紹了微信小程序網(wǎng)絡(luò)請(qǐng)求實(shí)現(xiàn)過程解析,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2019-11-11Hammer.js+輪播原理實(shí)現(xiàn)簡(jiǎn)潔的滑屏功能
這篇文章主要介紹了Hammer.js+輪播原理實(shí)現(xiàn)簡(jiǎn)潔的滑屏功能的相關(guān)資料,需要的朋友可以參考下2016-02-02