Articles → JAVASCRIPT → Window.Opener In Javascript
Window.Opener In Javascript
Purpose
Example
- ParentPage.html
- ChildPage.html
Parentpage.Html
<html>
<head>
<title>DOM example</title>
</head>
<body>
<form name="frmDefault">
<input type="text" name="txtName" id="txtName" />
<button value="Click" onclick="return TestOpener()">Click</button>
</form>
<script>
function TestOpener() {
window.open("ChildPage.html");
return false;
}
</script>
</body>
</html>
Try It
Childpage.Html
<html>
<body>
<form></form>
</body>
</html>
<script>
console.log(window.opener.document.getElementById("txtName"));
</script>
Output