1. 程式人生 > >在HTML頁面中獲取當前專案根路徑的方法

在HTML頁面中獲取當前專案根路徑的方法

本文轉載於:猿2048網站在HTML頁面中獲取當前專案根路徑的方法

在HTML頁面獲取專案根路徑的方法:

function getRootPath(){
    var curPageUrl = window.document.location.href;
    var rootPath = curPageUrl.split("//")[0] + curPageUrl.split("//")[1].split("/")[0] 
                   + "/" + curPageUrl.split("//")[1].split("/")[1];
    return