Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to run Chrome Extension
#5
Hi,

Yes, of course you can.

Taking the example from w3schools that you attached I went to the VB6 browser demo form and added a new button to the form called "AutoTranslateButton" and put the following code in the OnClick event.

Code:
Private Sub AutoTranslateButton_Click()   Dim sEle As String   Dim jScript As String   sEle = "const tempDiv = document.createElement('div');" & vbCrLf   sEle = sEle & "tempDiv.id = 'google_translate_element'" & vbCrLf   sEle = sEle & "document.body.insertAdjacentElement('afterbegin',tempDiv);" & vbCrLf   EdgeWebBrowser.ExecuteScript (sEle)   jScript = "" & vbCrLf   jScript = jScript & "function googleTranslateElementInit() {" & vbCrLf   jScript = jScript & "new google.translate.TranslateElement({pageLanguage: 'en'}, 'google_translate_element');" & vbCrLf   jScript = jScript & "}" & vbCrLf   EdgeWebBrowser.ExecuteScript (jScript)     sEle = "const tempScript = document.createElement('script');" & vbCrLf   sEle = sEle & "tempScript.type = 'text/javascript'" & vbCrLf   sEle = sEle & "tempScript.src = '//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit'" & vbCrLf   sEle = sEle & "document.body.insertAdjacentElement('beforeend',tempScript);" & vbCrLf   EdgeWebBrowser.ExecuteScript (sEle) End Sub

and that worked for me.

Navigating to the antwise.com website, then clicking the "Translate" button nicely inserted the google translate feature into the page.

   

Hope this helps,
--
Wil
Reply


Messages In This Thread
How to run Chrome Extension - by hys999 - 2023-07-12, 13:03:26
RE: How to run Chrome Extension - by wila - 2023-07-12, 15:50:48
RE: How to run Chrome Extension - by hys999 - 2023-07-12, 16:07:33
RE: How to run Chrome Extension - by hys999 - 2023-07-14, 05:25:43
RE: How to run Chrome Extension - by wila - 2023-07-14, 11:00:59
RE: How to run Chrome Extension - by hys999 - 2023-07-14, 16:49:37
RE: How to run Chrome Extension - by wila - 2023-07-14, 18:26:12
RE: How to run Chrome Extension - by hys999 - 2023-07-17, 05:39:25
RE: How to run Chrome Extension - by wila - 2023-07-17, 09:56:31

Forum Jump:


Users browsing this thread: 1 Guest(s)