【发布时间】:2012-09-15 18:54:42
【问题描述】:
我正在尝试使用带有 .NET 4 的 WinForms 中的 OpenWebKitSharp 调用 javascript
这是我尝试使用的代码。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using WebKit;
using WebKit.Interop;
using WebKit.JSCore;
using webkitForm.Properties;
namespace webkitForm
{
public partial class Form1 : Form
{
WebKitBrowser webKitSharpBrowser = new WebKitBrowser();
public Form1()
{
InitializeComponent();
this.Controls.Add(webKitSharpBrowser);
webKitSharpBrowser.Width = 600;
webKitSharpBrowser.Height = 400;
}
private void button1_Click(object sender, EventArgs e)
{
webKitSharpBrowser.Preferences.AllowPlugins = true;
webKitSharpBrowser.UseJavaScript = true;
webKitSharpBrowser.Navigate("http://sandbox.icontact.com");
webKitSharpBrowser.GetScriptManager.EvaluateScript("alert('An alert from C#!');"); //Call javascript?
}
}
}
我无法让 javascript 为任何事情触发...一定是我遗漏了什么。
提前致谢。
【问题讨论】:
-
好吧,看来答案就是问题。嗯,警报没有切换的原因对我来说是个谜,但其他 javascript 工作得很好。我想知道为什么有人给我这个问题的功劳。因为我猜它有效...
标签: c# javascript c#-4.0 webkit open-webkit-sharp