William
William

Reputation: 1069

Disable Alert boxes when site not found Gecko Fx VB

I been searching around and cant seem to find anything relating to this. Basically i made a windowless app which uses the gecko webbrowser. Thing is, if i try browse to a site that does not exist. Example: www.gets.commmss, it will show me an alert box saying www.gets.commmss could not be found. Please check the name and try again. I dont want this to show as i handle these errors myself using the navigated & NavigationError handlers. Thing is, i cant seem to disable this annoying alert box! Any ideas much apprecited.

The geckofx version i am using is: GeckoFX v33.0.9.0

I am using visual studio 2012 and it is a windows form application.

Screenshot:enter image description here

This must be done via the app somewere as i dont think this is a javascript thing?

Upvotes: 2

Views: 1371

Answers (2)

israfilgazi
israfilgazi

Reputation: 11

VB.net GeckoFx Disable Alert

Dim MyPath = My.Computer.FileSystem.CurrentDirectory
   Public Sub New()
        Xpcom.Initialize(MyPath + "\xulrunner")
        ' This call is required by the designer.
        InitializeComponent()
        Xpcom.ProfileDirectory = MyPath + "\profile"

        Gecko.PromptFactory.PromptServiceCreator = AddressOf PromptServiceCreator
    End Sub
    Function PromptServiceCreator()
        Dim val As New NoPromptService()
        Return val
    End Function
 
 
Public Class NoPromptService
    Inherits PromptService
    Public Overrides Sub Alert(ByVal dialogTitle As String, ByVal text As String)
        Debug.WriteLine(text)
    End Sub
End Class

Upvotes: 0

Sire
Sire

Reputation: 4358

You need to override the PromptService.Alert(). The following code works for GeckoFX 45:

public class NoPromptService : PromptService
{
    public override void Alert(string dialogTitle, string text)
    {
        Debug.WriteLine(text);
    }
}

Then run this after initializing GeckoFX:

PromptFactory.PromptServiceCreator = () => new NoPromptService();

I got this from an older answer on the GeckoFX issue tracker.

Upvotes: 5

Related Questions