ITeye博客

js 获取当前web应用的上下文路径

zwt2001267 · 2013-12-29 17:34 · JS · Web前端 · Markdown

function getWebRootPath() {
    var webroot=document.location.href;
    webroot=webroot.substring(webroot.indexOf('//')+2,webroot.length);
    webroot=webroot.substring(webroot.indexOf('/')+1,webroot.length);
    webroot=webroot.substring(0,webroot.indexOf('/'));
    var rootpath="/"+webroot;
    return rootpath;
}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。