js获取项目根路径
来源:互联网 发布:玛雅新域名 编辑:程序博客网 时间:2024/05/29 16:28
//js获取项目根路径,如: http://localhost:8083/uimcardprjfunctiongetRootPath(){ //获取当前网址,如: http://localhost:8083/uimcardprj/share/meun.jsp varcurWwwPath=window.document.location.href; //获取主机地址之后的目录,如: uimcardprj/share/meun.jsp varpathName=window.document.location.pathname; var pos=curWwwPath.indexOf(pathName); //获取主机地址,如: http://localhost:8083 varlocalhostPaht=curWwwPath.substring(0,pos); //获取带"/"的项目名,如:/uimcardprj varprojectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1); return(localhostPaht+projectName);}
以上代码在本地测试通过,于服务器就出现问题,于是请采用下面方法:
/**
*获取上下文
**/
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 0
- js获取项目根路径
- js获取项目根路径
- js获取项目根路径
- js获取项目根路径
- js获取项目根路径
- js获取项目根路径
- js获取项目根路径
- js获取项目根路径
- JS获取项目根路径
- js获取项目根路径
- JS获取项目根路径
- JS获取项目根路径
- js获取项目根路径
- js获取项目根路径
- JS 获取项目根路径
- js获取项目根路径
- js获取项目根路径
- js获取项目根路径
- JS刷新当前页面的几种方法总结
- HF集成AirKiss、微信局域网控制
- acm之动态规划题目3
- jenkins需要依赖其它插入
- accessibilityservice 自动安装 取消删除安装包
- js获取项目根路径
- 收藏的一些网址
- 各大公司docker容器云的技术栈对比
- qt 编译时提示error: multiple definition of
- 【dubbo】dubbo服务注册三种方式
- PHP APP开发笔记1
- poj 2382 Apple Catching 入门dp
- ubuntu genymotion 启动adb 被占用5037端口
- Invalid thread access