GitHub 博客园 Nanakon

☀【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>

 

posted on 2013-09-23 11:24  jzm17173  阅读(200)  评论(0编辑  收藏  举报

导航

轻音