react-native: [Android WebView] can't load url
I’m trying to load this URL https://gitter.im/login
in my web view component, but it doesn’t loads.
It just displays this:
I’ve tried to load it in a default android browser and it had loaded successfully.
Some code:
<View style={{flex: 1}}>
<WebView
ref='webview'
style={{height: 400}}
url={'https://gitter.im/login/'}
javaScriptEnabled={true}
domStorageEnabled={true}
onNavigationStateChange={this.onNavigationStateChange}
/>
</View>
I’m on 0.18.0-rc.
Also tried other URLs, and it works perfectly works well only if there is no js. It seems like a bug with enabling javascript.
Also tried to use javaScriptEnabledAndroid
, but nothing was change.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 4
- Comments: 43 (8 by maintainers)
Commits related to this issue
- Webview: Fix broken fullscreen modals due to zero body height. Summary: Supersedes PR #8536 Fixes #5211 JavaScript plugins such as Fotorama are broken when attempting use its fullscreen feature. If... — committed to immidi/react-native by danielbraun 8 years ago
- Webview: Fix broken fullscreen modals due to zero body height. Summary: Supersedes PR #8536 Fixes #5211 JavaScript plugins such as Fotorama are broken when attempting use its fullscreen feature. If... — committed to HomePass/react-native by danielbraun 8 years ago
Hi, I had this problem too but when I specify the width in the style then the page is now displayed/rendered.
This is because it cannot get the height of Webview to handle the CSS
height:100%
. Instead of injecting JS as a workaround, which may cause unexpected CSS bugs on the page (could happen on Android < 4.4 - since they are crappy), a fix could be adding this increateViewInstance()
ofReactWebViewManager.java
.but I don’t know if this will cause any other side effects.
@kevinejohn now it nested only inside some containers – Navigator and Root
I’ve fixed that by injection this js code:
I’ve spent several hours and managed to make all WebView pages to display on Android. I’m using version 0.30.
Hope it helps!
@geirman I’ll try with 0.23.0-rc1 and will write the result.
I figured it out. If you make the WebView as the parent instead of being nested in the View it loads the websites fine. Not exactly sure why.