Articles → JAVASCRIPT → Window.Opener In Javascript

Window.Opener In Javascript






Purpose





Example




  1. ParentPage.html
  2. 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="TestOpener()">Click</button>
        
    </form>

<script>
    function TestOpener() {

        window.open("ChildPage.html");

    }
</script>
</body>
</html>



Childpage.Html




<html>
<body>
    <form></form>
</body>

</html>
<script>
    console.log(window.opener.document.getElementById("txtName"));  

</script>



Output




Picture showing the parent page with a textbox and a button




Picture showing the outer HTML of the textbox of parent page



Posted By  -  Karan Gupta
 
Posted On  -  Friday, August 12, 2022

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250