react-native: Webview is not executing my JavaScript from the web page on Android?
Description
When I open WebView on Android emulator or real device it does not execute JavaScript. I have run simple Android App in Android Studio and it worked there.
Reproduction Steps
Just create a new app and add this WebView to it
Sample Code
<WebView
style={[styles.flex]} //styles
javaScriptEnabled={true} //enabling JavaScript
source={{uri: 'http://partners.zeew.eu/'}} //Url
/>
Solution
Can you please check it and say what is wrong?
Additional Information
- React Native version: 0.45.1
- Platform: Android ( not sure about iOS )
- Development Operating System: Windows
- Build tools: Android Studio: Nexus 5x edited_api_25 Android 6.0 Google APIs, Nexus 5 API level 26, Android 8.0.0
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 7
- Comments: 48 (5 by maintainers)
The community does not seem to be really strong and supportive.
@jayporta have u tried with
baseUrl=" "
baseUrl with empty string.Hey I’m also having a similar problem. Some of the javascript in my Android webview will fail to execute, but there seems to be no way to get debug information or error messages. Does anyone know how to read the console on the embedded webview? I have resorted to doing stuff like this:
Which obviously does not always work because sometimes javascript fails to execute in the webview and I cannot see the console output.
Javascript execution in webview is not working for android API version 21 and below. Anyone found any solution?
@pankaj-ag Thank you!
Why does an emulator WebView not work when same emulator’s native browser does work?
Try running on a real Android device.
I am not sure if anything more than javaScriptEnabled is needed.
May be this will help - https://stackoverflow.com/questions/35451139/react-native-webview-not-loading-any-url-react-native-web-view-not-working
somehow its not working in android emulator but its working fine in my device.
@ggsrivas thx! I have tried and find this problem, too. I used
let
… hahcan anyone tell me how to include <script> tag in webview?
For me the page loaded in the webview has no problem using JavaScript, but the injected JavaScript doesn’t get executed without
javaScriptEnabled
set to true