☀【window.self / window.parent / window.top】

Js中的window.parent ,window.top,window.self 详解 √
http://blog.csdn.net/zdwzzu2006/article/details/6047632

http://xxx/test1.html(同域)

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <title></title>
</head>
<body>
    <iframe src="test2.html"></iframe>
    <script>
        console.log(top === self)
        console.log(self === window)
        console.log(self)
        console.log(parent)
        console.log(top)
    </script>
</body>
</html>

test2.html

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <title></title>
</head>
<body>
    <script>
        console.log(top === self)
        console.log(self === window)
        console.log(self)
        console.log(parent)
        console.log(top)
    </script>
</body>
</html>
原文地址:https://www.cnblogs.com/jzm17173/p/3334510.html