js獲取當前路徑的簡單示例代碼
<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)絡地址:request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getRequestURI()
相關文章
JS實現(xiàn)同一個網(wǎng)頁布局滑動門和TAB選項卡實例
這篇文章主要介紹了JS實現(xiàn)同一個網(wǎng)頁布局滑動門和TAB選項卡效果,通過簡單的自定義切換函數(shù)setTab實現(xiàn)頁面元素的遍歷及屬性切換的功能,具有一定參考借鑒價值,需要的朋友可以參考下2015-09-09JavaScript代碼判斷輸入的字符串是否含有特殊字符和表情代碼實例
這篇文章主要介紹了JavaScript代碼判斷輸入的字符串是否含有特殊字符和表情,通過js代碼if語句進行判斷,并結(jié)合自己開發(fā)的情景,具體操作步驟大家可查看下文的詳細講解,感興趣的小伙伴們可以參考一下。2017-08-08用最簡單的方法判斷JavaScript中this的指向(推薦)
都說 JavaScript 是一種很靈活的語言,這其實也可以說它是一個混亂的語言,下面通過本文給大家分享JavaScript中this的指向知識,感興趣的朋友一起看看吧2017-09-09詳解如何通過JavaScript實現(xiàn)函數(shù)重載
這篇文章主要為大家詳細介紹了如何通過JavaScript實現(xiàn)函數(shù)重載,文中的示例代碼講解詳細,對我們學習JavaScript有一定的幫助,感興趣的可以了解一下2023-01-01