Heim  >  Artikel  >  Web-Frontend  >  javascript获取web应用根目录的方法_javascript技巧

javascript获取web应用根目录的方法_javascript技巧

WBOY
WBOYOriginal
2016-05-16 17:00:181227Durchsuche
复制代码 代码如下:

<script> <BR>function getRootPath(){ <BR>var strFullPath=window.document.location.href; <BR>var strPath=window.document.location.pathname; <BR>var pos=strFullPath.indexOf(strPath); <BR>var prePath=strFullPath.substring(0,pos); <BR>var postPath=strPath.substring(0,strPath.substr(1).indexOf(‘/')+1); <BR>return(prePath+postPath); <BR>} <BR>var webpath=getRootPath(); //webpath就是目录路径变量 <BR></script>
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn