Public Function OnBeforeResourceLoad(browserControl As IWebBrowser, objIBrowser As IBrowser, frame As IFrame, request As IRequest, callback As IRequestCallback) As CefReturnValue Implements IRequestHandler.OnBeforeResourceLoad Dim sb As New System.Text.StringBuilder
sb.AppendLine("document.getElementByTagName('html')[0].innerHTML;") Dim objTask As Task = browser.EvaluateScriptAsync(sb.ToString()) Dim myFunc = Function(t) If Not t.IsFaulted Then Dim response = t.Result If response.Success = True Then MessageBox.Show(response.Result.ToString()) End If End If End Function Try objTask.ContinueWith(myFunc, TaskScheduler.FromCurrentSynchronizationContext()) Catch ex As Exception Stop End Try
callback.Continue(True) Return CefReturnValue.ContinueAsync End Function
Hi,
I would like to request your help with a problem that I can’t figure out. I’m using the class from the example below, which is a separate class from the one where the Cef browser is created.
When MyMethod get’s called, how can I then use function:
Await CEFBrowser.EvaluateScriptAsync (in VB)?
Thanks,
3. How do you expose a .NET class to Javascript?
Like this:
public class BoundObject
{
public string MyProperty { get; set; }
public void MyMethod()
{
// Do something really cool here.
}
}
// ...
// After your ChromiumWebBrowser has been created
browser.RegisterJsObject("bound", new BoundObject());
In the actual JS code, you would use the object like this:
bound.myProperty; // use this syntax to access the property
bound.myMethod(); // use this to call the method.
--
You received this message because you are subscribed to a topic in the Google Groups "CefSharp" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cefsharp/wpRQXyOlnxE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cefsharp+u...@googlegroups.com.
To post to this group, send email to cefs...@googlegroups.com.
Visit this group at http://groups.google.com/group/cefsharp.
For more options, visit https://groups.google.com/d/optout.