I had two problems with my JavaScript.
- I used window.parent.document instead of window.opener.document
- For some reason, the .append () syntax prevents me from adding a cloned object
Instead, I had to use the .html () element hanging from the JQuery selector to pass the HTML from the clone to .append ().
Here is the end result:
CopyToThisPageFromTheParent('#accordion', '#testDiv'); function CopyToThisPageFromTheParent(openingWindowSelector, childWindowSelector) { var clone = $(openingWindowSelector, window.opener.document).clone(true); var theOuterHtml = clone.wrap('<div></div>').parent().html(); $(childWindowSelector).append(theOuterHtml); }
This assumes that I have this HTML:
<div id="testDiv"></div>
on my popup page, and this HTML:
<div id="accordion">something</div>
on my main page and used " window.open(); " to open a popup.
Thanks David
David source share