react-native-wkwebview icon indicating copy to clipboard operation
react-native-wkwebview copied to clipboard

How to use evaluateJavaScript to get iframe's elements (cors)?

Open abinli opened this issue 8 years ago • 1 comments

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!

abinli avatar Jul 25 '17 21:07 abinli

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.

jeremyong avatar Dec 05 '17 21:12 jeremyong