欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

js獲取當(dāng)前頁面路徑示例講解

 更新時(shí)間:2014年01月08日 09:59:19   作者:  
本篇文章主要是對(duì)js獲取當(dāng)前頁面路徑的示例代碼進(jìn)行了介紹,需要的朋友可以過來參考下,希望對(duì)大家有所幫助

設(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)文章

最新評(píng)論