-
-
Notifications
You must be signed in to change notification settings - Fork 25
Closed
Labels
Milestone
Description
Hi,
Is it possible to pass Javascript code back and execute JavaScript function/method from C#?
For example :
ScriptingService javascriptService = new ScriptingService();
IConfiguration config = Configuration.Default.WithDefaultLoader(setup => setup.IsResourceLoadingEnabled = true).With(javascriptService).WithCss();
string scriptJS = @"<script>
function getTitle() { return document.title; }
</script>";
IDocument ashDocument = await BrowsingContext.New(config).OpenAsync("http://html5test.com");
// How to insert scriptJS & excute getTitle() function?
// Perhaps to execute getTitle() function ....
JsValue jsGetTitle = javascriptService.Engine.GetJint(ashDocument).GetValue("getTitle");
string documentTitle = jsGetTitle.Invoke().AsString();
Console.WriteLine("Document Title: {0}", documentTitle);Reactions are currently unavailable