WolfyD
WolfyD

Reputation: 873

Navigating with Gecko Web Browser in C#

I'm using Geckofx 33.0.9.0 in my C# application, and I'm having a problem with navigating.

Generally it works well, I enter a URL and it takes me to a page. The problem is that if I enter a URL for a page that doesn't exist, it gives me a MessageBox titled 'Alert'.

1) This is really annoying. At least in my Opinion 2) I would really like to set it up, so if I navigate to a page that doesn't exist, it creates a google search from my url, like in most proper browsers.

I tried looking but Gecko isn'T really well documented, or at least I couldn't find it (Though if someone has documentation for it, that would be great!) and I couldn't find any other way of navigating other then the .Navigate('String Url/Uri') method.

What can I do to circumvent this Alert box? Is there a way?

I'm creating the GeckoWebBrowser Control in code btw.

I will of course post code if required.

Upvotes: 0

Views: 2095

Answers (1)

Bartosz
Bartosz

Reputation: 4766

to supress the alert message box you can try the following

        Xpcom.Initialize(Paths.XulRunner);
        GeckoPreferences.User["browser.xul.error_pages.enabled"] = false;
        GeckoPreferences.User["browser.download.manager.showAlertOnComplete"] = false;
        GeckoPreferences.User["security.warn_viewing_mixed"] = false;
        GeckoPreferences.User["privacy.popups.showBrowserMessage"] = false;

As for the second idea, well, that shouldn't be very hard - you just need to check in the DocumentCompleted or NavigationFinished event for a page status - if it's not correctly loaded, then take the address string bit and redirect to google url + your string.

Hope this helps!

Upvotes: 1

Related Questions