Copiar código del código de la siguiente manera:
<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 ();
</script>