代码示例:(标识:jsck_win_self_top)
<!DOCTYPE html>
<html>
<body>

<h1>Window 对象</h1>

<h2>self 和 top 属性</h2>

<p id="demo"></p>

<script>
let text;
if (window.top != window.self)  {
  text = "这不是最顶层的窗口!我在框架中吗?";
} else { 
  text = "这是最顶层的窗口!";
} 
document.getElementById("demo").innerHTML = text;
</script>

</body>
</html>
运行结果: