Launching Internet Explorer without address bar in .NET

I needed to launch an Internet Explorer window to a particular URL in a near “chromeless” fashion – no toolbar, no address bar, no scrollbars, from a C# .NET application. At first I used thread.start(url), but you cannot specify how Internet Explorer should open – there are no command line options to customize the window.

The internet failed me – I was supposed to reference some web COM dll, that I didn’t even have.

The solution is painfully simple. Make sure you have a reference to System.Windows.Forms, create a WebBrowser object in code (no need to add it to a form), give it an about:blank url, then use Document.Window.OpenNew() to launch a new IE window with parameters.

 

Examples speak louder than words: this snippet will open google in a new browser window

using (WebBrowser wb = new WebBrowser())
{
    wb.Url = new System.Uri("about:blank");
    wb.Document.Window.OpenNew("http://google.com", "location=no,menubar=no,scrollbars=no,status=yes,toolbar=no,resizable=yes");
}

If you will be opening a lot of windows, maybe you should keep the WebBrowser object in a class variable.

Maybe this one was out there somewhere, but I couldn’t find it…