js 获取 项目 根路径 JavaScript
2012-02-10 17:59
405 查看
/** * 获取项目根路径1 * @return {RootPath} * @author 李海云 */ function getRootPath1(){ var strFullPath=window.document.location.href; var strPath=window.document.location.pathname; var pos=strFullPath.indexOf(strPath); var prePath=strFullPath.substring(0,pos); var postPath=strPath.substring(0,strPath.substr(1).indexOf('/')+1)+"/"; return(prePath+postPath); } /** * 获取项目根路径2 * @return {RootPath} * @author 李海云 */ function getRootPath2() { var pathName = window.location.pathname.substring(1); var webName = pathName == '' ? '' : pathName.substring(0, pathName.indexOf('/')); return window.location.protocol + '//' + window.location.host + '/'+ webName + '/'; }
相关文章推荐
- JS获取当前网址、主机地址项目根路径
- javascript 在js文件中获取路径
- javascript 获取浏览器地址栏目中的资源路径+项目名
- js获取项目根路径
- js获取项目根路径
- 通过 javascript 获取项目根路径
- js文件中获取项目路径
- JS 获取项目根路径
- js获取项目根路径
- JS获取当前网址、主机地址项目根路径
- java 或者 js 获取项目访问路径(域名)
- 在独立的javascript文件中获取当前项目的http路径
- HTML页面使用js获取项目上下文路径
- js获取项目根路径
- js实现在HTML页面获取项目名路径
- js获取项目根路径
- js获取项目根路径
- javascript 获取项目根路径(备忘)
- JS获取项目根路径
- js获取项目根路径