Copy code code as follows:
<script>
function getrootpath () {
var sTRFULLLPATH = window.document.location.href;
var strpath = window.document.location.pathname;
var pos = strfullpath.indexof (strpath);
var Prepath = Strfullpath.substring (0, POS);
var postpath = strpath.substring (0, strpath.substr (1) .indexof ('/')+1);
Return (Prepath+Postpath);
}
var webpath = getrootpath (); // webpath is the directory path variable variable
</script>