获取浏览器地址栏中的地址截止到应用程序名称

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+"/"; 
}

 

posted @ 2019-04-15 08:49  ZhiPeng007  阅读(286)  评论(0编辑  收藏  举报