คัดลอกรหัสรหัสดังนี้:
<script>
ฟังก์ชั่น getrootpath () {
var strfulllpath = window.document.location.href;
var straph = window.document.location.pathName;
var pos = strfullpath.indexof (strpath);
var prepath = strfullpath.substring (0, pos);
var postpath = straph.substring (0, strpath.substr (1) .indexof ('/')+1);
return (prepath+postpath);
-
var webPath = getRootPath ();
</script>