First, thanks for all the answers.
I tried to do it the Tom-Sawyer-Way with a hidden element and it worked just fine (after some hours sitting in front of the computer).
Here's my solution:
Code:Private Function GetVarFromJavaScript(ByVal strJavascript As String, ByVal strJavaScriptVariable As String) Dim strNavigation As String = "" Dim strReturn As String WebBrowser.ScriptErrorsSuppressed = True strNavigation &= "javascript:" strNavigation &= strJavascript strNavigation &= "if(typeof " & strJavaScriptVariable & " == ""undefined"") " & strJavaScriptVariable & " = """";" strNavigation &= "if(typeof jsvar == ""undefined""){" strNavigation &= "var myElement = document.createElement('<input name=""source"" id=""jsvar"" type=""hidden"" value="""">');" strNavigation &= "myElement.value = " & strJavaScriptVariable & ";" strNavigation &= "document.body.appendChild(myElement);" strNavigation &= "var html = document.documentElement.outerHTML; document.write(html);" strNavigation &= "}else{" strNavigation &= "document.getElementById(""jsvar"").value = " & strJavaScriptVariable & ";doit();}" WebBrowser.Navigate(strNavigation) System.Windows.Forms.Application.DoEvents() Try strReturn = WebBrowser.Document.GetElementById("jsvar").DomElement.Value Catch strReturn = "" End Try Return strReturn End Function
And here's an example how to call the function:
Code:Private Function GetHTML() GetVarFromJavaScript("strdomain = document.domain;", "strdomain") End Sub




Reply With Quote