首页 > 技术文章 > 获取浏览器地址栏中的地址截止到应用程序名称

zhipeng007 2019-04-15 08:49 原文

function getContextPath() { 
    //获取域名
    var curl = document.domain;
    //获取应用程序名
    var contextPath = document.location.pathname; 
    var index =contextPath.substr(1).indexOf("/"); 
    contextPath = contextPath.substr(0,index+1); 
    delete index; 
    return "http://"+curl+contextPath+"/"; 
}

 

推荐阅读