获取当前域的top对象topWindow

//获取当前域的top对象topWindow 
window.topWindow = function () {
  var obj = window.self,
  t_obj = obj;
  try {
    if (window.top.location.host) {
      return window.top;
    }
  } catch (e) {
    while (true) {
      try {
          if (obj.location.host) {
            t_obj = obj;
            obj = obj.window.parent;
          }
        } catch (e) {
        return t_obj;
      }
    }
  }
}();

  

posted @ 2016-11-28 14:43  vzane  阅读(1764)  评论(0编辑  收藏  举报