获取当前网页的协议+域名(兼容IE)
时间:2021-08-17 20:24:31
收藏:0
阅读:25
// 获取当前网页的协议+域名 function getPageBaseUrl () { let baseURL = ‘‘ if (!window.location.origin) { // 兼容IE,IE11版本下location.origin为undefined window.location.origin = window.location.protocol + ‘//‘ + window.location.hostname + (window.location.port ? ‘:‘ + window.location.port : ‘‘) } else { baseURL = window.location.origin } return baseURL }
原文:https://www.cnblogs.com/wangweizhang/p/15153126.html
评论(0)