首頁 >web前端 >js教程 >js取得目前路徑的簡單範例程式碼_javascript技巧

js取得目前路徑的簡單範例程式碼_javascript技巧

WBOY
WBOY原創
2016-05-16 17:04:561116瀏覽

   
thisURL = document.URL;
thisHREF = document.location.href;
thisSLoc = self.location.href;
thisDLoc = document.location;
strwrite = " thisURL: [" thisURL "]
""
strwrite = " thisHREF: [" thisHREF "]
""
strwrite = " thisSLoc: [" thisS " ]
""
strwrite = " thisDLoc: [" thisDLoc "]
""
document.write( strwrite );

thisTLoc = top.location.href;
thisPLoc =parent.document.location;
thisTHost = top.location.主機名稱;
thisHost = 位置.主機名稱;
strwrite = " thisTLoc: [" thisTLoc "]
""
strwrite = " thisPLoc: [" thisPLoc "]
""
strwrite = " thisTHost: [" thisTHost " ]
""
strwrite = " thisHost: [" thisHost "]
""
document.write( strwrite );

tmpHPage = thisHREF.split( "/" );
thisHPage = tmpHPage[ tmpHPage.length-1 ]​​;
tmpUPage = thisURL.split( "/" );
thisUPage = tmpUPage[ tmpUPage.length-1 ]​​;
strwrite = " thisHPage: ["thisHPage "]
""
strwrite = " thisUPage: ["thisUPage "]
""
document.write( strwrite );
var url="";
警報(url)

request.getRequestURI();
request.getRequestURL();
request.getQueryString();

request.getServletPath()

可以取得自己的網路位址:request.getScheme() "://" request.getServerName() ":" request.getServerPort() request.getRequestURI()

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn