js獲取當(dāng)前路徑的簡單示例代碼
<script type="text/javascript">
thisURL = document.URL;
thisHREF = document.location.href;
thisSLoc = self.location.href;
thisDLoc = document.location;
strwrite = " thisURL: [" + thisURL + "]<br />"
strwrite += " thisHREF: [" + thisHREF + "]<br />"
strwrite += " thisSLoc: [" + thisSLoc + "]<br />"
strwrite += " thisDLoc: [" + thisDLoc + "]<br />"
document.write( strwrite );
thisTLoc = top.location.href;
thisPLoc = parent.document.location;
thisTHost = top.location.hostname;
thisHost = location.hostname;
strwrite = " thisTLoc: [" + thisTLoc + "]<br />"
strwrite += " thisPLoc: [" + thisPLoc + "]<br />"
strwrite += " thisTHost: [" + thisTHost + "]<br />"
strwrite += " thisHost: [" + thisHost + "]<br />"
document.write( strwrite );
tmpHPage = thisHREF.split( "/" );
thisHPage = tmpHPage[ tmpHPage.length-1 ];
tmpUPage = thisURL.split( "/" );
thisUPage = tmpUPage[ tmpUPage.length-1 ];
strwrite = " thisHPage: [" + thisHPage + "]<br />"
strwrite += " thisUPage: [" + thisUPage + "]<br />"
document.write( strwrite );
var url="<%=request.getRequestURI()%>";
alert(url)
</script>
request.getRequestURI();
request.getRequestURL();
request.getQueryString();
request.getServletPath()
可以得到自己的網(wǎng)絡(luò)地址:request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getRequestURI()
相關(guān)文章
解決循環(huán)中setTimeout執(zhí)行順序的問題
今天小編就為大家分享一篇解決循環(huán)中setTimeout執(zhí)行順序的問題,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-06-06
js 顯示base64編碼的二進(jìn)制流網(wǎng)頁圖片
base64簡單地說,它把一些 8-bit 數(shù)據(jù)翻譯成標(biāo)準(zhǔn) ASCII 字符,我們把圖像文件的內(nèi)容直接寫在了HTML 文件中,這樣做的好處是,節(jié)省了一個HTTP 請求2014-04-04
使用html+js+css 實(shí)現(xiàn)頁面輪播圖效果(實(shí)例講解)
下面小編就為大家?guī)硪黄褂胔tml+js+css 實(shí)現(xiàn)頁面輪播圖效果(實(shí)例講解)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-09-09
JavaScript面試中??嫉淖址僮鞣椒ù笕?包含ES6)
對于JavaScript字符串操作方法,你真的全部掌握了嗎?來看看這篇面試中??嫉淖址僮鞔笕钚碌腅S6字符串操作方法,值得收藏哦2020-05-05
js添加select下默認(rèn)的option的value和text的方法
這篇文章主要介紹了js中創(chuàng)建html標(biāo)簽、添加select下默認(rèn)的option的value和text,很實(shí)用,需要的朋友可以看看2014-10-10

