call me

iframe获取父级域名

不跨域:parent.location或top.location

跨域:document.referrer

function getParentUrl() { 
  var url = null;
  if (parent !== window) {
    try {
      url = parent.location.href; 
        }
    catch (e) {
      url = document.referrer; 
     } 
   }
  return url; 
}

  

参考:https://www.shangmayuan.com/a/bc07af30a9a04224a6ec4cdb.html

posted on 2021-09-02 10:35  黑松沙土  阅读(864)  评论(0)    收藏  举报

导航