我是靠谱客的博主 哭泣含羞草,这篇文章主要介绍js 获取 项目 根路径 JavaScript,现在分享给大家,希望可以做个参考。

原文地址:http://blog.csdn.net/lihaiyun718/article/details/7249487

 

  1. /** 
  2.  * 获取项目根路径1 
  3.  * @return {RootPath} 
  4.  * @author 李海云 
  5.  */  
  6. function getRootPath1(){  
  7.     var strFullPath=window.document.location.href;  
  8.     var strPath=window.document.location.pathname;  
  9.     var pos=strFullPath.indexOf(strPath);  
  10.     var prePath=strFullPath.substring(0,pos);  
  11.     var postPath=strPath.substring(0,strPath.substr(1).indexOf('/')+1)+"/";  
  12.     return(prePath+postPath);  
  13. }  
  14. /** 
  15.  * 获取项目根路径2 
  16.  * @return {RootPath} 
  17.  * @author 李海云 
  18.  */  
  19. function getRootPath2()   
  20. {   
  21.      var pathName = window.location.pathname.substring(1);  
  22.      var webName = pathName == '' ? '' : pathName.substring(0, pathName.indexOf('/'));  
  23.      return window.location.protocol + '//' + window.location.host + '/'+ webName + '/';   
  24. }  


最后

以上就是哭泣含羞草最近收集整理的关于js 获取 项目 根路径 JavaScript的全部内容,更多相关js内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(137)

评论列表共有 0 条评论

立即
投稿
返回
顶部