js 判断是当前页是否在框架的最顶层

if (window.top !== window.self) { // are you trying to put self in an iframe?
  try {
    if (window.top.location.host) { // this is illegal to access unless you share a non-spoofable document domain
      // fun times
    } else {
      bust(); // chrome executes this
    }
  } catch (ex) {
    bust(); // everyone executes this
  }
}


你可能感兴趣的:(js 判断是当前页是否在框架的最顶层)