Answers for "if script is within iframe javascript"

7

how to get element in iframe using javascript

const iframe = document.getElementById("myIframe");

const iWindow = iframe.contentWindow;
const iDocument = iWindow.document;

// accessing the element
const element = iDocument.getElementsByTagName("p")[0];
element.style.color = "green";
Posted by: Guest on October-21-2021
1

iframe innerthtml

//Make sure to select 'top' from JS context dropdown menu in chrome devtools console

document.querySelector('iframe class/id').contentWindow.document.querySelector('body').innerHTML
Posted by: Guest on October-14-2021

Code answers related to "if script is within iframe javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language