Search code examples
javascriptgeckofx

How do I enable Javascript to function properly in GeckoFX?


I've started to use GeckoFX but I got a major issue with javascript:void(0) that acts as anchor which lets JS to pop new window and load url. How do I tell browser to do this INSIDE the geckobrowser component? RIght now, when I click it..nothing happens.


Solution

  • To handle a new browser window, you need to handle the CreateWindow event of the GeckoWebBrowser. Then you open a new form with a web browser control, and set e.WebBrowser to that control:

    private void webBrowser_CreateWindow(object sender, GeckoCreateWindowEventArgs e) {
      BrowserForm frm = new BrowserForm();
      e.WebBrowser = frm.WebBrowser;
      frm.Show();
    }