React
by davecranwell
HTML
<iframe id="myframe" src="//fiddle.jshell.net/xpvt214o/show/">
</iframe>
React
function ready(fn) {
if (document.attachEvent ? document.readyState === "complete" : document.readyState !== "loading"){
fn();
} else {
document.addEventListener('DOMContentLoaded', fn);
}
}
ready(() => {
const frame = document.getElementById('myframe');
frame.addEventListener('load', (e) => {
const buttons = frame.contentWindow.document.querySelectorAll('button');
console.log('frame loaded', buttons );
console.log([...buttons]);
});
});