SoFunction
Updated on 2025-04-06

How to get the root directory of a web application in javascript


<script>
function getRootPath(){
var strFullPath=;
var strPath=;
var pos=(strPath);
var prePath=(0,pos);
var postPath=(0,(1).indexOf(‘/')+1);
return(prePath+postPath);
}
var webpath=getRootPath(); //webpath is the directory path variable
</script>