Retrieve return value of a Javascript function in the WebBrowser control in vb6

前端 未结 2 1778
我在风中等你
我在风中等你 2021-01-03 11:41

I have a vb6 application,

I make a function call with WebBrowser script but I need to get the return value of that function

my current function is

         


        
2条回答
  •  太阳男子
    2021-01-03 11:55

    1. Assign return value of your JavaScript function to JavaScript variable.
    2. Use execScript method of WebBrowser.Document.ParentWindow to call your JavaScript code.
    3. Now retrieve value of the variable via WebBrowser.Document.Script. in VB6.

      Private Sub cmdJsFunc_Click()
          Dim retVal As String
      
          Call WebBrowser1.Document.parentWindow.execScript("v = function(){return 3.14;}; tempJsVar=v();")
          retVal = WebBrowser1.Document.Script.tempJsVar
      
          MsgBox retVal
      End Sub
      

提交回复
热议问题