I get a challenge when apply webview. I want to inject Javascript function to my webview, but it only work in iOS not in Android.
Look to my code :
Webview :
<WebView
source={{uri:"http://mywebview.com/webview.php"}}
injectedJavaScript={jsCode}
mixedContentMode={'compatibility'}
javaScriptEnabledAndroid={true}
style={{height: 300}} />
JSCode to Inject :
let jsCode = `function doPopUp() {
document.querySelector('#myBody').style.backgroundColor = 'red';
alert('hello world from webview');
}`;
In iOS it works fine, but not in Android. If i not inject the JS (i put it directly in php file) and then open in Android Browser it works fine. Additional information for you is, if i'm not put syntax inside a js function it works fine. Why? and how to fix it?
domStorageEnabled={true}inWebView. hope it worksdoPopUp()function in yourhttp://mywebview.com/webview.phpfile?? Do you have any HTML component with idmyBody??