Maison > interface Web > js tutoriel > le corps du texte

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

WBOY
Libérer: 2016-05-16 17:00:18
original
1227 Les gens l'ont consulté
复制代码 代码如下:

<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>
Étiquettes associées:
source:php.cn
Déclaration de ce site Web
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
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!