public void EvaluateJavaScript(string javascript) { try { var mf = CurrentBrowser.GetMainFrame(); mf.ExecuteJavaScriptAsync(javascript); // this is fire and forget can run js urls, startLine } catch (Exception e) { Console.WriteLine(@"JS error: " + e.Message); } }
public async void EvaluateJavaScript(string javascript, string callback) { try { var mf = CurrentBrowser.GetMainFrame(); var response = await mf.EvaluateScriptAsync(javascript, TimeSpan.FromMilliseconds(500).ToString()); if (response.Success && response.Result is IJavascriptCallback javascriptCallback) { response = await javascriptCallback.ExecuteAsync(""); } Context.DispatchEvent(WebViewEvent.AsCallbackEvent, response.ToJsonString(callback)); } catch (Exception e) { Context.DispatchEvent(WebViewEvent.AsCallbackEvent, e.ToJsonString(callback)); } }
public void NavigateTo(string url) { CurrentBrowser.StopLoad(); CurrentBrowser.GetMainFrame().LoadUrl(url); }