I am trying to get the HTML contents of a child window, and then take those contents and append it to the parent window. It is not working!!!! It alerts 'undefined' every time. Very annoying. How do I get this to work?
JavaScript in the parent Window:
function openW() {
var url = this.href,
childW = window.open(url);
// shows .html class of child window
alert($(childW.document).find('.hidden').html());
}
$('.item').click(function(event) {
event.preventDefault();
openW();
});
Then in the HTML of the parent window, I have a link to the child window and a class of 'item'.
Also, even in the console log, if I type childW, it shows 'undefined'. I don't know what is going on.
EDIT
Based off the duplicate in question, here is the code I tried:
childW = window.open(url);
$(childW.document).ready(function () {
alert($(childW.document).contents().find('.hidden').html());
});
Not working.