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

前端 未结 2 1756
我在风中等你
我在风中等你 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.<JavaScript variable name, case-sensitive> 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
      
    0 讨论(0)
  • 2021-01-03 12:07

    Try:

    Set v = WebBrowser1.Document.parentWindow("v = function(){return callOther();};v()")
    
    0 讨论(0)
提交回复
热议问题