I am currently using :
function printThing(){
let link = parent.document.getElementById("oLink").href;
console.log(link);
}
if (window.attachEvent) {window.attachEvent("onload", printThing);}
else if (window.addEventListener) {window.addEventListener("load", printThing, false);}
else {document.addEventListener("load", printThing, false);}
To get a link from the contents of an iframe (which uses srcdoc instead of src) and print it in the console. This code will be added to some stored html before being sent to the frontend.
Is there a way to trigger this once the iframe content is loaded (ie without having to wait for other content in the app)? I tried replacing all the window
with document
but it doesnt work (it does nothing).
I need to access elements from inside the iframe and change their attributes.