0

Even though there are similar questions to mine js open popup window and acces it's element in another page , the solution there didn't work for me ..

I am trying to open a window onclick, and then access a certain element and edit its content , but it's not working..

Here is the parent html

 <!doctype html>
<html>

<head>
    <title>Parent</title>
    <script src="opener.js"></script>
    <meta charset="utf-8"/>
 </head>

<body>
    <button class="w3-btn w3-container"  id = "submit_btn">Submit</button>
</body>

</html>

Child html

   <!doctype html>

<html>
<head>
    <title>Pre:D</title>
    <link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css"> 
    <meta charset="utf-8"/>
</head>

<body>
    <input class="w3-input" type="text" id="input_word"  placeholder="enter your word here">
    <div id="dump" style = "width: 800px"> </div>
</body>
</html>

and here is the opener.js script

window.onload = function(){

document.getElementById("submit_btn").onclick= run;

};

function run(){
    var myWindow = window.open('child.html', "width=850,height=600");

    myWindow.onload = function() {
        myWindow.document.getElementById("dump").innerHTML = 'Janela: ';
    }  
}

Best

Community
  • 1
  • 1
Mortada
  • 35
  • 7

0 Answers0