日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 前端技术 > HTML >内容正文

HTML

.net 内嵌 GeckoWebBrowser (firefox) 核心浏览器

發(fā)布時(shí)間:2024/9/20 HTML 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 .net 内嵌 GeckoWebBrowser (firefox) 核心浏览器 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

引用nuget包:

注意:Geckofx45 nuget包必須是最后引用,否則初始化會(huì)出錯(cuò)

簡(jiǎn)單示例:

using Gecko; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms;namespace WindowsFormsApp2 {public partial class Form1 : Form{GeckoWebBrowser gecko;public Form1(){InitializeComponent();Xpcom.Initialize("Firefox");gecko = new GeckoWebBrowser();gecko.CreateControl();gecko.NoDefaultContextMenu = true; //禁用右鍵菜單gecko.Dock = DockStyle.Fill;panel1.Controls.Add(gecko);gecko.ProgressChanged += Gecko_ProgressChanged;gecko.CreateWindow += Gecko_CreateWindow;gecko.DocumentCompleted += Gecko_DocumentCompleted;gecko.Navigate("http://www.baidu.com");}private void Gecko_DocumentCompleted(object sender, Gecko.Events.GeckoDocumentCompletedEventArgs e){//var executor = new Gecko.JQuery.JQueryExecutor(gecko.Window); //先獲取到j(luò)query對(duì)象//executor.ExecuteJQuery("$('#a')"); //然后執(zhí)行jquery的代碼using (AutoJSContext context = new AutoJSContext(gecko.Window)){string result;context.EvaluateScript("3 + 2;", out result);context.EvaluateScript("'hello' + ' ' + 'world';", out result);}progressBar1.Value = 0;}private void Gecko_CreateWindow(object sender, GeckoCreateWindowEventArgs e){e.InitialHeight = 500;e.InitialWidth = 500;}private void Gecko_ProgressChanged(object sender, GeckoProgressEventArgs e){if (e.MaximumProgress == 0 )return;var value = (int)Math.Min(100, (e.CurrentProgress * 100) / e.MaximumProgress);if (value == 100)return;progressBar1.Value = value;}} }

總結(jié)

以上是生活随笔為你收集整理的.net 内嵌 GeckoWebBrowser (firefox) 核心浏览器的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。