zoukankan      html  css  js  c++  java
  • C#获取当前页面的url

       C#获取当前页面的url

             string a=   Request.ApplicationPath;            //   /
             string b = Request.CurrentExecutionFilePath;    //   /WebForm1.aspx
             string c = Request.FilePath;                    //   /WebForm1.aspx
             string d = Request.PhysicalApplicationPath;    //    c:users纯访documentsvisual studio 2013ProjectsWebApplication4WebApplication4 
             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

    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title></title>
        <script>  
            document.write("=============1==============================================="+ "<br>");
            thisURL = document.URL;                                                          
            thisHREF = document.location.href;
            thisSLoc = self.location.href;
            thisDLoc = document.location;
            strwrite = "<tr><td valign=top>thisURL: </td><td>[" + thisURL + "]</td></tr><br>"; 
            strwrite += "<tr><td valign=top>thisHREF: </td><td>[" + thisHREF + "]</td></tr><br>";
            strwrite += "<tr><td valign=top>thisSLoc: </td><td>[" + thisSLoc + "]</td></tr><br>";
            strwrite += "<tr><td valign=top>thisDLoc: </td><td>[" + thisDLoc + "]</td></tr><br>";
            document.write(strwrite);
            document.write("<br>"+"=============1===============================================" + "<br>");
        </script>
        <script> 
            document.write("<br>" + "=============2===============================================" + "<br>");
            thisTLoc = top.location.href;
            thisPLoc = parent.document.location;
            thisTHost = top.location.hostname;
            thisHost = location.hostname;
            strwrite = "<tr><td valign=top>thisTLoc: </td><td>[" + thisTLoc + "]</td></tr><br>";
            strwrite += "<tr><td valign=top>thisPLoc: </td><td>[" + thisPLoc + "]</td></tr><br>";
            strwrite += "<tr><td valign=top>thisTHost: </td><td>[" + thisTHost + "]</td></tr><br>";
            strwrite += "<tr><td valign=top>thisHost: </td><td>[" + thisHost + "]</td></tr><br>";
            document.write(strwrite);
            document.write("<br>" + "=============2===============================================" + "<br>");
        </script>
        <script>  
            document.write("<br>" + "=============3===============================================" + "<br>");
            tmpHPage = thisHREF.split("/");
            thisHPage = tmpHPage[tmpHPage.length - 1];
            tmpUPage = thisURL.split("/");
            thisUPage = tmpUPage[tmpUPage.length - 1];
            strwrite = "<tr><td valign=top>thisHPage: </td><td>[" + thisHPage + "]</td></tr><br>";
            strwrite += "<tr><td valign=top>thisUPage: </td><td>[" + thisUPage + "]</td></tr><br>";
            document.write(strwrite);
            document.write("<br>" + "=============3===============================================" + "<br>");
        </script>
    
    </head>
    <body>
        <table width=100% cellpadding=0 cellspacing=0 border=0>
            <tbody>=================条目=============================</tbody><br />
            thisDLoc = document.location;
            <br>
            thisURL = document.URL;
            <br>
            thisHREF = document.location.href;
            <br>
            thisSLoc = self.location.href;
            <br>
           
            thisTLoc = top.location.href;
            <br>
            thisPLoc = parent.document.location;
            <br>
            thisTHost = top.location.hostname;
            <br>
            thisHost = location.hostname;
            <br>
    
    <tr><td>
        </table>
    </body>
    </html>

    效果:

    =============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; 
  • 相关阅读:
    Jmeter之定时器
    Jmeter环境部署及目录解析
    Linux之shell脚本(基础篇)
    Linux常用命令
    Nginx详细安装部署教程(转)
    lsyncd+rsync文件实时同步
    windows7下搭建robot framework环境
    Python 类和实例
    第一个自动化运维程序
    Python之 set的特点
  • 原文地址:https://www.cnblogs.com/laopo/p/5476723.html
Copyright © 2011-2022 走看看