Answer the question
In order to leave comments, you need to log in
How to send message in iframe in webview?
I have a webview component
<WebView
ref={webView => (this.webView = webView)}
originWhitelist={['*']}
source={{
html: `<iFrame id="payture-iframe" name="paytureIframe" width="100%" height="450px" src=${this.props.url} frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iFrame>`,
}}
onMessage={this.onMessageHandler}
style={{ flex: 1, width: '100%', height: '100%' }}
/>
this.webView.postMessage(JSON.stringify({ type: 'sendOrder' }), '*');
Answer the question
In order to leave comments, you need to log in
There is 1 request to pass data to webview. To do this, you need to call the function like this
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>WebView1</title>
<meta forua="true" http-equiv="Cache-Control" content="max-age=0"/>
</head>
<script type="text/javascript">
function testEcho(test){
alert(test);
}
</script>
</body>
</html>
return this.webview&&this.webview.injectJavaScript("testEcho("+JSON.stringify({...result,token:this.state.accessToken})+");")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question