injectedJavaScript no working
See original GitHub issueHello,
Bug description: I have UPGRADE my old app, for accept by Apple i need remove UIWebview, so i have update react-native-webview 6.0.0 to 10.3.2 but now injectedJavaScript no working…
My old code :
const disableZoom = "const meta = document.createElement('meta'); meta.setAttribute('content', 'initial-scale=1.0, maximum-scale=1.0'); meta.setAttribute('name', 'viewport'); document.getElementsByTagName('head')[0].appendChild(meta);";
<WebView
style={stylesLive.webview}
source={{uri: 'https://www.twitch.tv/embed/hebo/chat?parent=tiboy.fr'}}
injectedJavaScript={disableZoom}
scalesPageToFit={false}
useWebKit={true}
/>
I have try :
const jsCode = "document.querySelector('.HeaderHero').style.backgroundColor = 'purple';";
<WebView
ref={ref => {
this.webview = ref;
}}
source={{ uri: 'https://reactnative.dev' }}
javaScriptEnabledAndroid={true}
injectedJavaScript={jsCode}
/>
How to pass code now? I would like to deactivate the zoom of the webview, especially when I select a field it zooms me all without zooming out after … two days that I test, search all the possible posts on the net and test other codes …
Environment:
- OS: MAC OS X
- OS version: 10.15.5
- react-native version: 0.62.2
- react-native-webview version: 10.3.2
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:5 (1 by maintainers)
Top Results From Across the Web
injectedJavaScript is not working in IOS · Issue #1779 - GitHub
I am using "injectedJavaScript" in webview, this property is working fine in android but not working in ios. Code import React, { Component...
Read more >injectedJavaScript is not working in Webview of react native
Well, you have more than one issue here. First one is your web view needs to be wrapped in a containing View component...
Read more >why react native webview injectedJavascript doesn't work on ...
Coding example for the question why react native webview injectedJavascript doesn't work on IOS?-React Native.
Read more >Need help with react-native Webview, injecting react ... - Reddit
The string interpolation doesn't work. What should I do if I'm trying to pass data from react native into the javascript string that's ......
Read more >React Native WebView: A complete guide - LogRocket Blog
The JavaScript code that is provided to the injectedJavaScript prop is only going to be ... Without this prop, the scripts will not...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Linrasis, the documentation in the react-native-webview repository about how the injectedJavaScript property works is outdated. Now you need to set an onMessage event (an empty one it’s ok) in order to the code within the injectedJavaScript property to be executed. Below you can see an example of this. Hope it may help you.
Thank You @lrusso. This worked for me.