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

[Android WebView] can't load url

Open terrysahaidak opened this issue 10 years ago • 43 comments

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.

terrysahaidak avatar Jan 09 '16 01:01 terrysahaidak

Hey terrysahaidak, thanks for reporting this issue!

React Native, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. There are just too many issues for us to manage properly.

  • If you don't know how to do something or something is not working as you expect but not sure it's a bug, please ask on StackOverflow with the tag react-native or for more real time interactions, ask on Discord in the #react-native channel.
  • If this is a feature request or a bug that you would like to be fixed, please report it on Product Pains. It has a ranking feature that lets us focus on the most important issues the community is experiencing.
  • We welcome clear issues and PRs that are ready for in-depth discussion. Please provide screenshots where appropriate and always mention the version of React Native you're using. Thank you for your contributions!

facebook-github-bot avatar Jan 09 '16 01:01 facebook-github-bot

Do other pages load? Can you open chrome://inspect and see if you can debug the issue?

satya164 avatar Jan 10 '16 12:01 satya164

@satya164 yup, it does. But I still cant load gitter.im site. It loads welcome screen, then I'm login through GitHub and redirecting back, but it doesn't loads. And when I'm trying to visit it again with my cookies, it won't load. I think it isn't the problem with Gitter because there is an app for android called Developer Talks where the user should login through webview.

I'll try to inspect it later and let you know.

And sorry for my English :)

terrysahaidak avatar Jan 10 '16 17:01 terrysahaidak

@satya164 I've debugged the issue and I assume that it doesn't render the HTML.

I can also submit the form with this code:

var submit = document.getElementById('allow')
submit.click()

terrysahaidak avatar Jan 11 '16 19:01 terrysahaidak

Also tried to load this URL with this app (github) and it works.

terrysahaidak avatar Jan 11 '16 20:01 terrysahaidak

No console errors?

tomauty avatar Jan 11 '16 20:01 tomauty

@tomauty no. BTW I'm running it in 5.1.1 on my sgs4 i9505.

It seems like a magic :smile:

terrysahaidak avatar Jan 11 '16 20:01 terrysahaidak

Just tried it with 0.19.0-rc and got the same result. :worried:

terrysahaidak avatar Jan 28 '16 14:01 terrysahaidak

Just got it working by deleting some css code. But still can't realize why it does not work like native webview?

I've disabled height: 100% html tag's rule (the best result i've got because of that). And got it:

terrysahaidak avatar Jan 31 '16 23:01 terrysahaidak

+1 I'm running into the same issue with certain websites.

kevinejohn avatar Feb 08 '16 04:02 kevinejohn

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.

kevinejohn avatar Feb 08 '16 10:02 kevinejohn

@kevinejohn now it nested only inside some containers -- Navigator and Root

I've fixed that by injection this js code:

const jsForInjection = `
  var el = document.getElementsByTagName('body')[0];
  el.style.height = '${Dimensions.get('window').height}px';
`

terrysahaidak avatar Feb 08 '16 15:02 terrysahaidak

@terrysahaidak that worked. Thanks!

kevinejohn avatar Feb 08 '16 22:02 kevinejohn

This is happening to us too, a url that used to load correctly in RN WebView 0.18 is now a blank screen since RN 0.19

maraujop avatar Feb 15 '16 10:02 maraujop

@maraujop could you inspect the web view with chrome://inspect?

terrysahaidak avatar Feb 15 '16 13:02 terrysahaidak

@terrysahaidak Sure, I've inspected the webview, This url renders a widget that gets inflated through some javascript execution. It looks like the javascript never executed because the widget is not inflated, however the console shows no errors and it used to work before.

maraujop avatar Feb 15 '16 14:02 maraujop

did you use webview's javaScriptEnabled property?

because in my issue HTML was rendered, but not displayed.

terrysahaidak avatar Feb 15 '16 15:02 terrysahaidak

Thanks Terry for your help, but yes, javaScriptEnabled is set to true. I've just upgraded to 0.20-rc and it works again, so I guess it is fixed already.

maraujop avatar Feb 15 '16 16:02 maraujop

@terrysahaidak i have the same issue , a blank html, looks like many page redirection cause it, and how can i inspect my rn-app in chrome ? i connect my phone by usb, and just could see LG-D858 #LGD858DB61B26E , no inspect button, but when i open mobile browser and open a page , the chrome inspect page show the inspect button ,but not belong to my app, how can i debugge the rn-webview? thanks a lot~

oillamp avatar Mar 04 '16 12:03 oillamp

@oillamp connect you phone via USB, allow USB debugging and then got to this url chrome://inspect in chrome, then you'll see your device and page that currently opened in webview

hmm, it should display your rn-webview. try to use another webview (you can find it on react.parts or github)

terrysahaidak avatar Mar 04 '16 14:03 terrysahaidak