function getBaseUrl() {
var ishttps = 'https:' == document.location.protocol ? true : false;
var url = window.location.host;
if (ishttps) {
url = 'https://' + url;
} else {
url = 'http://' + url;
}
return url;
}

本文介绍了一个JavaScript函数,用于根据当前页面的HTTPS状态和主机名获取基础URL。此函数首先检查页面是否通过HTTPS加载,然后根据结果构建并返回相应的URL。
2万+

被折叠的 条评论
为什么被折叠?



