javascript中如何得到base url?


程序中需要动态的添加base url到字符串前面。如何通过javascript实现呢?

绝对地址 base_url JavaScript

懒洋洋的橙 11 years ago
function getBaseURL () {
   return location.protocol + "//" + location.hostname + (location.port && ":" + location.port) + "/";
}
flyang answered 11 years ago

Your Answer