Js gets the simple sample code for the current path

  • 2020-03-30 01:14:36
  • OfStack

< The script type = "text/javascript" >      
ThisURL = document. The URL;
ThisHREF = document. Location. Href;
ThisSLoc = self. Location. Href;
ThisDLoc = document. The location;
Strwrite = "thisURL: [" + thisURL + "]< Br / >"
Strwrite += "thisHREF: [" + thisHREF + "]< Br / >"
Strwrite += "thisSLoc: [" + thisSLoc + "]< Br / >"
Strwrite += "thisDLoc: [" + thisDLoc + "]< Br / >"
Document. The write (strwrite);

ThisTLoc = top. Location. Href;
ThisPLoc = parent. The document. The location;
ThisTHost = top. The location. The hostname;
ThisHost = location. The hostname;
Strwrite = "thisTLoc: [" + thisTLoc + "]< Br / >"
Strwrite += "thisPLoc: [" + thisPLoc + "]< Br / >"
Strwrite += "thisTHost: [" + thisTHost + "]< Br / >"
Strwrite += "thisHost: [" + thisHost + "]< Br / >"
Document. The write (strwrite);

TmpHPage = thishref.split ("/");
ThisHPage = tmpHPage[tmphpage.length-1];
TmpUPage = thisurl.split ("/");
ThisUPage = tmpUPage[tmpupage.leng-1];
Strwrite = "thisHPage: [" + thisHPage + "]< Br / >"
Strwrite += "thisUPage: [" + thisUPage + "]< Br / >"
Document. The write (strwrite);
Var url = "< % = request. GetRequestURI () % >" ;
Alert (url)
< / script>

Request. GetRequestURI ();
Request. GetRequestURL ();
Request. GetQueryString ();

Request. GetServletPath ()

You can get your own network address: request-getscheme ()+"://"+ request-getservername ()+":"+ request-getserverport ()+ request-getrequesturi ()


Related articles: