C#获取当前页面的url
string a= Request.ApplicationPath; // / string b = Request.CurrentExecutionFilePath; // /WebForm1.aspx string c = Request.FilePath; // /WebForm1.aspx string d = Request.PhysicalApplicationPath; // c:\users\纯访\documents\visual studio 2013\Projects\WebApplication4\WebApplication4\ string ee = Request.RawUrl; // /WebForm1.aspx string f = Request.Url.AbsolutePath; // /WebForm1.aspx string g = Request.Url.AbsoluteUri; // http://localhost:7251/WebForm1.aspx string h = Request.Url.Host; // localhost string i = Request.Url.LocalPath; // /WebForm1.aspx
JS 获取当前页面的url
效果:
=============1===============================================thisURL: [http://localhost:7251/HtmlPage2.html]thisHREF: [http://localhost:7251/HtmlPage2.html]thisSLoc: [http://localhost:7251/HtmlPage2.html]thisDLoc: [http://localhost:7251/HtmlPage2.html]=============1============================================================2===============================================thisTLoc: [http://localhost:7251/HtmlPage2.html]thisPLoc: [http://localhost:7251/HtmlPage2.html]thisTHost: [localhost]thisHost: [localhost]=============2============================================================3===============================================thisHPage: [HtmlPage2.html]thisUPage: [HtmlPage2.html]=============3================================================================条目=============================thisDLoc = document.location; thisURL = document.URL; thisHREF = document.location.href; thisSLoc = self.location.href; thisTLoc = top.location.href; thisPLoc = parent.document.location; thisTHost = top.location.hostname; thisHost = location.hostname;