示例#1
0
 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);
     }
 }
示例#2
0
        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));
            }
        }
示例#3
0
 public void NavigateTo(string url)
 {
     CurrentBrowser.StopLoad();
     CurrentBrowser.GetMainFrame().LoadUrl(url);
 }