简体   繁体   中英

React native webview javascript simulate click

Hello i use Tidio for live chat and i put it in my react native app using webview

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


<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.

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.

Hope this helps!

Check tidio Api... The Api supports it... tidio.open()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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