For say i have a Site called example.com on which iframe is embedded of domain iframe.net, now i want to read the content of iframe and pass some parameter to display a text
Cross Domain iframe elements access in React with (srcDoc):-
onclickinsideiframe=()=>{ if(document.getElementById('iframetnd')!==null){ let iframe = document.getElementById('iframetnd'); let innerDocument = (iframe.contentDocument) ? iframe.contentDocument : iframe.contentWindow.document; let Obj = innerDocument.getElementsByClassName("navButtons")[0]; if(Obj !== undefined){ Obj.onclick = ()=>this.func(); } } } func=()=>{ this.setState({page:2}) this.arrangeTest(); }