DOCUMENT / 文档

Window parent 属性

Window parent 属性

Window parent 属性

Window 对象

定义和用法

parent属性返回当前窗口的父窗口。

语法

window.parent

浏览器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主要浏览器都支持 parent 属性

实例

实例

当打开新窗口时,在父窗口弹出警告:

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title>W3Cschool教程(w3cschool.cn)</title>

</head>

<head>

<script>

function openWin(){

    window.open('','','width=200,height=100');

    alert(window.parent.location);

}

</script>

</head>

<body>


<input type="button" value="打开窗口" onclick="openWin()">


</body>

</html>
尝试一下 »

Window 对象