简体   繁体   English

React Native webview javascript 模拟点击

[英]React native webview javascript simulate click

Hello i use Tidio for live chat and i put it in my react native app using webview您好,我使用 Tidio 进行实时聊天,我使用 webview 将其放入我的 react 本机应用程序中

it appears like that看起来像这样在此处输入图像描述

and then it needs to click on the chat icon to open the chat box like that然后它需要点击聊天图标来打开这样的聊天框在此处输入图像描述

I want it to open the chat box directly not to show the welcome message,我希望它直接打开聊天框而不显示欢迎消息,

I tried to use injectedJavaScript but it doesn't work我尝试使用注入的JavaScript,但它不起作用


<WebView
        javaScriptEnabled={true}
        injectedJavaScript={`(function() { document.getElementById('button-body').click()})();`}
        source={{
          uri: 'https://www.tidio.com/talk/ekmt9gtdgbc4rou29f7tuwvpbhcotzmx'
        }}
      />

Using WebView you can find a button and click it by loading a url, but in your case what you are doing wrong is you are finding a button which is loaded from iframe and trying to click it which is not possible.使用 WebView,您可以找到一个按钮并通过加载 url 来单击它,但在您的情况下,您做错了什么是您找到了一个从 iframe 加载的按钮,并且尝试单击它是不可能的。

If you really don't want to show the first page replace texts on the screen with your own text like you can replace welcome to iLampagency.com to Hi welcome to chat bot some thing like that.如果您真的不想显示第一页,请将屏幕上的文本替换为您自己的文本,例如,您可以将welcome to iLampagency.com替换为Hi welcome to chat bot

Hope this helps!希望这可以帮助!

Check tidio Api... The Api supports it... tidio.open()检查 tidio Api... Api 支持它... tidio.open()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM