1. 程式人生 > >JavaScript 伺服器地址獲取

JavaScript 伺服器地址獲取

 var urlPath = window.document.location.href;  //瀏覽器顯示地址 http://10.15.5.83:5555/ISV/demo.aspx?a=1&b=2
 var docPath = window.document.location.pathname; //檔案在伺服器相對地址 /ISV/demo.aspx
 var index = urlPath.indexOf(docPath);
 var serverPath = curWwwPath.substring(0, index);//伺服器地址 http://10.15.5.83:5555