In a project of mine, I need to work with unbound WebBrowser controls. The goal is to navigate simultaneously to several web pages, using several WebBrowser controls, and showing the individual pages when the user requests them pressing a button, binding the needed WebBrowser control to a container control in the form to display them.
Problem: Whenever one of the WebBrowser controls loads a page that focuses a control on the page by means of scripting, my Form gets deactivated after document complete if the WebBrowser control is not showing. This only happens with pages that focus an element on load (for example, using onload attribute in body tag but not only).
Reproduce code (using www.msn.com since this site focusses the search textbox after document complete):
In a standard new VB Windows Forms Application (with Form1), drop a button (Button1) in the Form1 designer and this code in the code editor:
Public Class Form1
Private wb As New WebBrowser
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Expected result from running the Application and pressing Button1:
The unbound and invisible WebBrowser control loads the msn page, the form Form1 stays activated.
View Complete Post