javascript - How to get html of parent window tags in child window? -


i opening child window parent window following code :

<html> <head>  </head>  <script type="text/javascript">     function foo(){       window.open("child.html","child window"); } </script>  <body id="data">  <img src = "2.jpg"> <button id="button1" name="nicebutton" onclick="foo()">click here</button>   </body> </html> 

in child window want html of parent windows body tags . use following code :

        <html> <head>  </head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>  <script type="text/javascript" language="javascript" src="html2canvas.min.js"></script> <script type="text/javascript" language="javascript" src="html2canvas.js"></script>  <script type="text/javascript">      function capture() {             window.alert('test');              html2canvas(window.opener.$("body")             ,{                 onrendered: function (canvas) {                                                  var imgstring = canvas.todataurl("image/png");                             window.open(imgstring);                    }             }         );     } </script>  <body id="d" onload="capture()">   <button id="button1" name="nicebutton" onclick="capture()">click here</button>  </body> </html> 

but getting following error :

typeerror: window.opener.$ not function 

how can resolve error ?

what need : need innerhtml of parent windows body tag .would following code work ?

alert($("window.opener.body")) ;  

replace capture function with

function capture() {         window.alert('test');          html2canvas(window.opener.document.body         ,{             onrendered: function (canvas) {                                              var imgstring = canvas.todataurl("image/png");                         window.open(imgstring);                }         }     ); } 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -