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版DateAdd和DateDiff函數(shù)代碼
VBScript中有兩個非常好用的日期操作函數(shù):DateAdd用來給日期添加指定時間間隔,DateDiff用來返回兩個日期的時間間隔??上У氖荍avaScript沒有,不過我們可以寫一個函數(shù)來實現(xiàn),一樣的,呵呵2012-03-03
JavaScript實現(xiàn)帶播放列表的音樂播放器實例分享
這篇文章主要介紹了JavaScript實現(xiàn)帶播放列表的音樂播放器實例分享,包括對播放完歌單之后沒有將要播放的歌曲的提示功能,需要的朋友可以參考下2016-03-03
手寫的一個兼容各種瀏覽器的javascript getStyle函數(shù)(獲取元素的樣式)
這篇文章主要介紹了手寫的一個兼容各種瀏覽器的javascript getStyle函數(shù),用來取元素的樣式,需要的朋友可以參考下2014-06-06

