window.location.origin 兼容IE

时间:2020-03-20 13:34:24   收藏:0   阅读:61

Ie浏览器下,有时候获取到的window.location.origin为undefined,需要兼容

let origin: any;
        if (!window.location.origin) {
          origin = window.location.protocol + ‘//‘ + window.location.hostname + (window.location.port ? ‘:‘ + window.location.port : ‘‘);
        } else {
          origin = window.location.origin;
        }

 

原文:https://www.cnblogs.com/huangmin1992/p/12530249.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!