Maison  >  Article  >  interface Web  >  javascript获取web应用根目录的方法_javascript技巧

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

WBOY
WBOYoriginal
2016-05-16 17:00:181226parcourir
复制代码 代码如下:

<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>
Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn