ホームページ  >  記事  >  ウェブフロントエンド  >  javascript_javascriptスキルでWebアプリケーションのルートディレクトリを取得する方法

javascript_javascriptスキルでWebアプリケーションのルートディレクトリを取得する方法

WBOY
WBOYオリジナル
2016-05-16 17:00:181227ブラウズ
コードをコピーします コードは次のとおりです。

function getRootPath(){
var strFullPath=window.document.location.href;
var strPath=window.document.location.pathname;
var pos=strFullPath.indexOf(strPath); (0, pos);
var postPath=strPath.substring(0,strPath.substr(1).indexOf('/') 1);
return(prePath postPath); var webpath= getRootPath(); //webpath はディレクトリ パス変数
声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。