Description
-- Please use this template, and delete everything above this line before submitting your issue ---
Description
The Webview's source is HTML code, will inject JS while onLoad callback executed. This is ok for Android, but, for iOS, the onLoad's callback is even NOT called...
constructor() {
super()
this.webView = null
this.injectJavaScript = this.injectJavaScript.bind(this)
}
injectJavaScript() {
alert(1); // Even not walk here
const bridgeJS = `
document.addEventListener("message", function(event) {
window.scrollTo(0, event.data);
}, false);
window.addEventListener("message", function(event) {
window.scrollTo(0, event.data);
}, false);
`
if (this.webView) {
this.webView.injectJavaScript(bridgeJS)
}
}
<WebView
ref={ webView => this.webView = webView}
source={ {html: ' <html><body><div style="height: 3000px;">13232</div></body></html>'} }
javaScriptEnabled={true}
domStorageEnabled={true}
onMessage={this._onMessage}
onLoad={this.injectJavaScript}
/>this code works well on Android, but, even NOT call onLoad to inject JavaScript in iOS...
Meanwhile, if I put the HTML to local directory, and use another approach to direct the source like
source={ require('../xxx.html') } is work fine on iOS.
Solution
I want to know why even NOT call onLoad's callback when set source: {html: '...'} in iOS.
But, it's ok for Android with same code...
Help me, thanks!
Additional Information
React Native version: 0.44.2
Platform: iOS / Android
Operating System: MacOS
Activity
colorfulberry commentedon Jun 19, 2017
Any others suffered this question?
Mahaswami commentedon Jul 18, 2017
+1
beilunyang commentedon Sep 18, 2017
+1
pull-bot commentedon Oct 10, 2017
@facebook-github-bot no-template
pull-bot commentedon Oct 10, 2017
@facebook-github-bot no-template
facebook-github-bot commentedon Oct 10, 2017
Hey, thanks for reporting this issue! It looks like your description is missing some necessary information, or the list of reproduction steps is not complete. Can you please add all the details specified in the Issue Template? This is necessary for people to be able to understand and reproduce the issue being reported. I am going to close this, but feel free to open a new issue with the additional information provided. Thanks! See "What to Expect from Maintainers" to learn more.
facebook-github-bot commentedon Oct 10, 2017
Hey, thanks for reporting this issue! It looks like your description is missing some necessary information, or the list of reproduction steps is not complete. Can you please add all the details specified in the Issue Template? This is necessary for people to be able to understand and reproduce the issue being reported. I am going to close this, but feel free to open a new issue with the additional information provided. Thanks! See "What to Expect from Maintainers" to learn more.
amirharel-fyber commentedon Apr 19, 2018
is this issue going to be fixed?
Damoness commentedon Jul 2, 2018
I has the same issue