简体   繁体   English

如何将搜索引擎添加到 GeckoFx 网络浏览器?

[英]How to add search engine to GeckoFx web browser?

I am implementing a custom browser based on Geckofx, i wanted to add a search engine where you can type any word and it search your document for coincidences, similar to Ctrl+F我正在实现一个基于 Geckofx 的自定义浏览器,我想添加一个搜索引擎,您可以在其中输入任何单词并搜索您的文档以寻找巧合,类似于 Ctrl+F

Is there already a way to do this in geckofx?在 geckofx 中已经有办法做到这一点了吗?

EDIT: This works in GeckoFx 29, it does not work in GeckoFx 45编辑:这适用于 GeckoFx 29,它不适用于 GeckoFx 45

I know about one method that is not entirely satisfying - but maybe that will give you a starter info...我知道一种并不完全令人满意的方法 - 但也许这会给你一个入门信息......

private void Find(bool backward)
        {
            string searchString = FindOnPageBox.Text;
            var field = typeof(GWB).GetField("WebBrowser", BindingFlags.Instance | BindingFlags.NonPublic);
            nsIWebBrowser nsIWebBrowser = (nsIWebBrowser)field.GetValue(TheBrowser);
            var browserFind = Xpcom.QueryInterface<nsIWebBrowserFind>(nsIWebBrowser);
            browserFind.SetSearchStringAttribute(searchString);
            browserFind.SetMatchCaseAttribute(YourProgramName.Settings.CaseSensitiveSearch);
            try
            {
                browserFind.SetWrapFindAttribute(true);
                browserFind.SetFindBackwardsAttribute(backward);
                browserFind.FindNext();
            }
            catch { }
        }

And then invoke it on btn clicks...然后在 btn 点击时调用它...

private void findOnPage_Next_Button_Click(object sender, RoutedEventArgs e)
        {
            Find(false);
        }

Have a look at this post: Find, HighLight, Scroll toText in Geckofx Web Page .看看这篇文章:在 Geckofx 网页中查找、突出显示、滚动到文本

Written with VB.net 2010. It also works in Vb.net 2017.用 VB.net 2010 编写。它也适用于 Vb.net 2017。

Currently I am using in Windows 10 and the latest Geckofx60 and is working.目前我在 Windows 10 和最新的 Geckofx60 中使用并且正在工作。 Perfectly not always as I wrote it when using XuLRunner but the original code is their to modify to perfection if so desired.完全不像我在使用 XuLRunner 时写的那样,但如果需要,原始代码是他们可以修改到完美的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM