react-native-wkwebview
react-native-wkwebview copied to clipboard
How to use evaluateJavaScript to get iframe's elements (cors)?
Hi,
While the react-native-wkwebview loads the iframe content elements correctly, I cannot get the iframe elements by issuing evaluateJavaScript js code:
var ifrm = document.getElementById("iframeID"); var ifrmContent = (ifrm.contentWindow || ifrm.contentDocument);
ifrmContent.document throws js error.
How to work around this (cors)?
Thanks!
You can't do this by design and is unrelated to this package. It's a function of how the web security model works. You need to either add cors headers yourself on the iframe contents or ask the party hosting content to whitelist you.