ホームページ  >  記事  >  ウェブフロントエンド  >  WebサイトのJavaScriptコードとパス(サイトと仮想ディレクトリ)を取得_JavaScriptスキル

WebサイトのJavaScriptコードとパス(サイトと仮想ディレクトリ)を取得_JavaScriptスキル

WBOY
WBOYオリジナル
2016-05-16 18:44:041123ブラウズ
复制代码代码如下:

<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>アラート (getRootPath()); <br></script>
声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。