本文整理汇总了C#中WebControl.ExecuteJavascript方法的典型用法代码示例。如果您正苦于以下问题:C# WebControl.ExecuteJavascript方法的具体用法?C# WebControl.ExecuteJavascript怎么用?C# WebControl.ExecuteJavascript使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebControl
的用法示例。
在下文中一共展示了WebControl.ExecuteJavascript方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: selectCategory
/// <summary>
/// Настраивает фильтр аукциона на определенную категорию
/// </summary>
/// <param name="wc">Браузер</param>
/// <param name="browserValue">Уникальное название категории</param>
private static void selectCategory(WebControl wc, string browserValue)
{
//Выбираем элемент option с названием нужной категории предмета, затем наживаем кнопку OK на форме
string jsFunction = "$('[value=\"" + browserValue + "\"]')[0].selected=true;$('[name=\"_filterapply\"]')[0].click();";
wc.ExecuteJavascript(jsFunction);
}
示例2: ResizeJavascript
public static void ResizeJavascript(WebControl webControl, float x, float y)
{
if (!webControl.IsLive) { return; }
webControl.ExecuteJavascript("resize(" + Convert.ToString(x).Replace(',', '.') + ", "
+ Convert.ToString(y).Replace(',', '.') + ")");
}
示例3: ByIDSetValue
public static Boolean ByIDSetValue( WebControl webBrowser, String id, String text ) {
try {
if ( webBrowser != null ) {
webBrowser.Invoke( new Action( () => webBrowser.ExecuteJavascript( String.Format( "document.getElementById( {0} ).value=\"{1}\";", id, text ) ) ) );
return true;
}
}
catch ( Exception exception ) {
exception.Error();
}
return false;
}
示例4: ClickSubmit
public static Boolean ClickSubmit( WebControl webBrowser, int index = 0 ) {
try {
if ( webBrowser != null ) {
webBrowser.Invoke( new Action( () => webBrowser.ExecuteJavascript( String.Format( "document.querySelectorAll(\"button[type='submit']\")[{0}].click();", index ) ) ) );
return true;
}
}
catch ( Exception exception ) {
exception.Error();
}
return false;
}
示例5: CreateRenderable
/// <summary>
/// Create a new visual to render.
/// </summary>
/// <returns></returns>
private WebControl CreateRenderable()
{
// Get the web control.
var pControl = new WebControl();
// Create a web-session with our settings.
if (pWebSession == null)
{
pWebSession = WebCore.CreateWebSession(new WebPreferences()
{
EnableGPUAcceleration = Properties.Settings.Default.EnableGPUAcceleration,
Databases = Properties.Settings.Default.EnableWebDatabases,
WebGL = Properties.Settings.Default.EnableWebGL,
WebSecurity = Properties.Settings.Default.EnableWebSecurity,
FileAccessFromFileURL = Properties.Settings.Default.EnableWebFileAccessFromFileURL,
Plugins = true,
});
}
pControl.WebSession = pWebSession;
// Set the render dimensions.
pControl.Width = this.RenderResolution.X;
pControl.Height = this.RenderResolution.Y;
// Hide the surface while we load.
if (ActiveSurface != null)
ActiveSurface.ContentOpacity = 0.01;
// When the process has been createad, bind the global JS objects.
// http://awesomium.com/docs/1_7_rc3/sharp_api/html/M_Awesomium_Core_IWebView_CreateGlobalJavascriptObject.htm
pControl.ProcessCreated += (object sender, EventArgs e) =>
{
// CALLING window.Surface = {} in JS here has no effect.
// Bind all the Authority.request and Authority.call methods.
Log.Write("Display Process Created (1)", this.ToString(), Log.Type.AppError);
BindAPIFunctions(pControl);
};
UrlEventHandler p = null;
p = new UrlEventHandler((object senderOuter, UrlEventArgs eOuter) =>
{
// Unbind this handler.
pControl.DocumentReady -= p;
// Force a re-load so the $(document).ready will have access to our Authority.request etc.
pControl.Reload(false);
// CALLING window.Surface = {} in JS here has no effect.
//SignalSurfacePropertiesChanged();
Log.Write("Display DocReady (1)", this.ToString(), Log.Type.AppError);
// Bind the other events.
#region Events
// Handle navigating away from the URL in the load instruction.
pControl.AddressChanged += (object sender, UrlEventArgs e) =>
{
// Rebind the API methods?
Log.Write("Display has changed web address. " + e.Url, this.ToString(), Log.Type.DisplayInfo);
};
// Handle console messages.
pControl.TitleChanged += (object sender, TitleChangedEventArgs e) =>
{
this.Title = e.Title;
};
// Document ready.. do we beat JQuery?
pControl.DocumentReady += (object sender, UrlEventArgs e) =>
{
// Show the surface now we are loaded.
if (ActiveSurface != null)
ActiveSurface.ContentOpacity = 1.0;
// CALLING window.Surface = {} in JS here does not work quick enough.
Log.Write("Display DocReady (2)", this.ToString(), Log.Type.AppError);
SignalSurfacePropertiesChanged();
// EXPERIMENTAL - this sort of works.. depends on how the page detects touch events..
// SEE: Nice example: http://paulirish.com/demo/multi
// SEE: Nicer example: Bing maps!
// Try to inject multi-touch into the page.
if (ActiveSurface.AttemptMultiTouchInject)
{
pControl.ExecuteJavascript(Properties.Resources.MultiTouchInject);
}
};
// Handle changes in responsiveness.
pControl.ResponsiveChanged += (object sender, ResponsiveChangedEventArgs e) =>
{
// If it is not responsive, log the problem.
if (!e.IsResponsive)
{
//.........这里部分代码省略.........