-1

For my project I used webBrowser control and when I launch an html site which has got an input(type) button with onclick javascript function which process ending on window.open target="_blank", it's internet explorer window that's is opening in place of a new page of webBrowser.

I program in c# code with winform technology and I used webBrowser System.Windows.Forms.

So which function could I used to open the page of this site in webBrowser window in place of IE window.

Thanks you for your help.

M.A.

  • https://stackoverflow.com/questions/6470842/how-do-i-display-a-popup-from-a-webbrowser-in-another-window-i-created – Hans Passant May 08 '21 at 16:34
  • the document that you present to me shows how to invoke a new form or a pop-up into webBrowser control but my problematic is that I want to launch the site after an input click "window.open" into webBrowser control instead of IE windows. – marc-antoine yonga May 08 '21 at 19:46

2 Answers2

0

Read about WebBrowser.Navigating event:

You can handle the Navigating event to cancel navigation if certain conditions have not been met, for example, when the user has not completely filled out a form. To cancel navigation, set the Cancel property of the WebBrowserNavigatingEventArgs object passed to the event handler to true. You can also use this object to retrieve the URL of the new document through the WebBrowserNavigatingEventArgs.Url property.

To open page in default browser, for example:

private void webBrowser_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
    e.Cancel = true;
    Process.Start(e.Url.ToString());
}
BorisSh
  • 531
  • 4
  • 3
  • I used the function "Navigating" but it is unoperational. the page is the first page of the site and not the page following the input button click. I inform you that the site that I want to load into webBrowser has got javascript function with input button and "window.open" functions. thanks you. – marc-antoine yonga May 08 '21 at 19:40
0

Finally,

I used the package reference "SHDocVm" of "Microsoft Internet Controls" and I place a function handler NewWindow3 in the function "DocumentCompleted" of webBrowser and it's ok, a window.open() javascript function with target="_blank" opens a new page of webBrowser.

Truly yours.

M.A.