这个有关问题小弟我百度了一天了,有前辈帮小弟我看下吗?关于kindeditor 编辑器操作的
这个问题我百度了一天了,有前辈帮我看下吗?关于kindeditor 编辑器操作的
是关于这个编辑器的
http://kindeditor.net/ke4/examples/default.html
我想知道用webBrowser控件怎么 执行里面的editor.html() 方法.并获得该方法执行后返回的值....
谢谢各位前辈了.以下是图片..说简单些我就是想知道怎么执行网页里的按钮点击后产生事件执行的哪个方法.这里我不是要点击这个按钮...我也是想知道以后遇到这种命令,我该怎么去调用网页里的命令. 我试过InvokeMember() 和InvokeScript() 返回值都是空的...
我实在搞不定了...求各位前辈,姐姐,哥哥,大叔拉小弟一把!! 感激不尽....


------解决方案--------------------
我刚才是直接打开你给的那个演示的网页的,模拟点击"取得HTML"那的按钮的。不知道你是不是自己用kindeditor做的页面。下面的代码是直接调用editor.html()
参考: Using WebBrowser.Document.InvokeScript() to mess around with foreign JavaScript
是关于这个编辑器的
http://kindeditor.net/ke4/examples/default.html
我想知道用webBrowser控件怎么 执行里面的editor.html() 方法.并获得该方法执行后返回的值....
谢谢各位前辈了.以下是图片..说简单些我就是想知道怎么执行网页里的按钮点击后产生事件执行的哪个方法.这里我不是要点击这个按钮...我也是想知道以后遇到这种命令,我该怎么去调用网页里的命令. 我试过InvokeMember() 和InvokeScript() 返回值都是空的...
我实在搞不定了...求各位前辈,姐姐,哥哥,大叔拉小弟一把!! 感激不尽....
------解决方案--------------------
我刚才是直接打开你给的那个演示的网页的,模拟点击"取得HTML"那的按钮的。不知道你是不是自己用kindeditor做的页面。下面的代码是直接调用editor.html()
参考: Using WebBrowser.Document.InvokeScript() to mess around with foreign JavaScript
using System;
using System.Windows.Forms;
namespace kindeditor
{
/// <summary>
/// Description of MainForm.
/// </summary>
public class MainForm : Form
{
/// <summary>
/// Designer variable used to keep track of non-visual components.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Disposes resources used by the form.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent()
{
this.webBrowser1 = new System.Windows.Forms.WebBrowser();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// webBrowser1
//
this.webBrowser1.Location = new System.Drawing.Point(12, 33);
this.webBrowser1.MinimumSize = new System.Drawing.Size(20, 20);
this.webBrowser1.Name = "webBrowser1";
this.webBrowser1.Size = new System.Drawing.Size(760, 516);
this.webBrowser1.TabIndex = 0;
this.webBrowser1.Url = new System.Uri("", System.UriKind.Relative);
//
// button1
//
this.button1.Location = new System.Drawing.Point(12, 4);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.Button1Click);
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(784, 561);
this.Controls.Add(this.button1);
this.Controls.Add(this.webBrowser1);
this.Name = "MainForm";
this.Text = "kindeditor";
this.ResumeLayout(false);
}
private System.Windows.Forms.Button button1;
private System.Windows.Forms.WebBrowser webBrowser1;
public MainForm()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
webBrowser1.DocumentCompleted +=
new WebBrowserDocumentCompletedEventHandler(DocumentLoaded);
webBrowser1.Navigate("http://kindeditor.net/ke4/examples/default.html");
}
private void DocumentLoaded(object sender, WebBrowserDocumentCompletedEventArgs e) {
}
void Button1Click(object sender, EventArgs e)
{
if (webBrowser1.ReadyState == WebBrowserReadyState.Complete)
{
HtmlDocument doc = webBrowser1.Document;
//doc.GetElementsByTagName("input").GetElementsByName("getHtml")[0].InvokeMember("click");
string result = sendJS(webBrowser1, "editor.html()");
MessageBox.Show(result);
}
}
private string sendJS(WebBrowser sender, string JScript) {
object[] args = {JScript};
return sender.Document.InvokeScript("eval",args).ToString();
}
}
}