本文整理汇总了C#中System.Windows.Controls.WebBrowser.InvokeScript方法的典型用法代码示例。如果您正苦于以下问题:C# WebBrowser.InvokeScript方法的具体用法?C# WebBrowser.InvokeScript怎么用?C# WebBrowser.InvokeScript使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.WebBrowser
的用法示例。
在下文中一共展示了WebBrowser.InvokeScript方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public override void Run(WebBrowser webBrowser, Action callBack = null)
{
var Script = string.Format("$('{0}').val('ok');", mJquerySelectObject);
webBrowser.InvokeScript("execScript", new Object[] { Script, "JavaScript" });
Script = string.Format("window.external.ClickHtmlElement($('{0}')[0]);",mJquerySelectObject);
webBrowser.InvokeScript("execScript", new Object[] { Script, "JavaScript" });
if(callBack != null)
callBack();
}
示例2: BrowserMouseHelper
public BrowserMouseHelper(WebBrowser browser)
{
_browser = browser;
if (true)//browser.Source != null)
{
var border0 = VisualTreeHelper.GetChild(_browser, 0);
var border1 = VisualTreeHelper.GetChild(border0, 0);
var panZoom = VisualTreeHelper.GetChild(border1, 0);
var grid = VisualTreeHelper.GetChild(panZoom, 0);
border = VisualTreeHelper.GetChild(grid, 0) as Border;
if (border != null)
{
border.ManipulationStarted += Border_ManipulationStarted;
border.ManipulationDelta += Border_ManipulationDelta;
border.ManipulationCompleted += Border_ManipulationCompleted;
border.DoubleTap += Border_DoubleTap;
border.Hold += Border_Hold;
border.MouseLeftButtonDown += Border_MouseLeftButtonDown;
}
try
{
_browser.InvokeScript("execScript", MinifiedMouseScript);
}
catch (Exception)
{
Debug.WriteLine("BrowserHelper Failed to install mouse script in WebBrowser");
}
}
browser.Loaded += new RoutedEventHandler(browser_Loaded);
}
示例3: handle
public async Task<bool> handle(WebBrowser browser, Uri uri)
{
Credentials creds;
try
{
creds = await requestCredentials(uri);
}
catch (TaskCanceledException)
{
return false;
}
string authScript = "(function() {var xhr = new XMLHttpRequest();xhr.open('HEAD', '{0}', false, '{1}', '{2}');xhr.send();})()";
authScript = authScript.Replace("{0}", uri.ToString());
authScript = authScript.Replace("{1}", creds.username.Replace("\\", "\\\\"));
authScript = authScript.Replace("{2}", creds.password);
Debug.WriteLine("Injecting script: {0}", authScript);
try
{
browser.InvokeScript("eval", new string[] { authScript });
return true;
}
catch (Exception)
{
return false;
}
}
示例4: Run
public override void Run (WebBrowser webBrowser, Action callBack = null)
{
var Script = string.Format("$('{0}').click();", mJquerySelectObject);
webBrowser.InvokeScript("execScript", new Object[] { Script, "JavaScript" });
if (callBack != null)
callBack();
}
示例5: dummyHandler
private void dummyHandler(Object sender, EventArgs e, String eventName, String handle, WebBrowser wb)
{
var payload = "{\"_hnd\": \"" + handle +
"\", \"type\": \"" + eventName +
"\", \"sender\": " + parseObject(sender) +
", \"eventArgs\": " + parseObject(e) +
"}";
try
{
wb.InvokeScript("handleEvent", payload);
}
catch (Exception) {}
}
示例6: Run
public override void Run (WebBrowser webBrowser, Action callBack = null)
{
webBrowser.InvokeScript("execScript", new Object[] { Script, "JavaScript" });
}