Example #1
0
 protected void ExecuteJavaScript(IWpfWebBrowser browser, string s)
 {
     try
     {
         _Logger.Debug($"Execute Javascript {s}");
         if (browser.IsBrowserInitialized)
         {
             browser.ExecuteScriptAsync(s);
         }
         else
         {
             browser.LoadingStateChanged += (sender, args) =>
             {
                 //Wait for the Page to finish loading
                 if (args.IsLoading == false)
                 {
                     browser.ExecuteScriptAsync(s);
                 }
             };
         }
     }
     catch (Exception e)
     {
         MessageBox.Show("Error while executing Javascript: " + e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Example #2
0
 private void ExecuteJavaScript(string s)
 {
     try
     {
         webBrowser.ExecuteScriptAsync(s);
     }
     catch (Exception e)
     {
         MessageBox.Show("Error while executing Javascript: " + e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Example #3
0
 private void WrapExecuteScriptAsync(string jsCode)
 {
     try
     {
         _wpfWebBrowser.ExecuteScriptAsync(jsCode);
     }
     catch (Exception)
     {
         // ignored
     }
 }