javascript - How to append a chunk of html to a loaded html page using window.open() method -


i'm trying append chunk of html loaded html page via window.open() method. example chunk of html string.

var w = window.open('mypage.html, 'windowname', 'scrollbars=yes,location=no,toolbar=no,status=no,width=500,height=550,left=300,top=50'); var htmlchunk = '<span>bla bla</span>'  $(w.document.body).append( htmlchunk ); 

$(w.document.body) doesn't seem able body tag on mypage.html inside popup.

i tried using ready method.

 $(w.document.body).ready(function(){          $(this).find('body').append(htmlchunk);      }); 

this didn't work either appending window below popup.

just clear here i'm not looking add js mypage.html directly. need able access popup mypage.html body tag , append chunk of html that. setup, have js file inside main.html page. in main.html page have link has click event on setup inside js file. call popup , capture block of html main.html page append mypage.html inside popup.

you can this:

$(w).on("load", function(){     $("body", w.document).append( htmlchunk ); }); 

the onload event handler makes code wait until new window has been created, , using w.document jquery's second argument sets context on new window. cannot run jquery instance child window because doesn't load jquery.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -