Welcome Guest Search | Active Topics | Sign In | Register

NewWindow event not triggering Options
chuarte
Posted: Thursday, March 9, 2023 11:01:03 AM
Rank: Newbie
Groups: Member

Joined: 3/9/2023
Posts: 2
Hello,
I'm trying out EO.WebBrowser and I need to open a new Window. I'm following the documentation (https://www.essentialobjects.com/doc/webbrowser/advanced/new_window.aspx) but when I try to assign the NewWindow event to the webView it doesn't trigger when I try to open a new url. It does open in any web browser (Chrome, etc), but not here.

Here I add the handler
private void checkEventsWebBrowser()
{
webView1.JSExtInvoke += new JSExtInvokeHandler(WebView_JSExtInvoke);
webView2.JSExtInvoke += new JSExtInvokeHandler(WebView_JSExtInvoke);

webView1.NewWindow += new NewWindowHandler(WebView_NewWindow);
webView2.NewWindow += new NewWindowHandler(WebView_NewWindow);
}

And here I the NewWindow

void WebView_NewWindow(object sender, NewWindowEventArgs e)
{
Form modalNostic = new Form();
EO.WinForm.WebControl webControl = new EO.WinForm.WebControl();
webControl.Dock = DockStyle.Fill;
modalNostic.Controls.Add(webControl);
webControl.WebView = e.WebView;
modalNostic.Show();
e.Accepted = true;

}

When I click it doesn't go into the function. Is there any other aproach to this?

Thank you very much.
eo_support
Posted: Thursday, March 9, 2023 4:45:46 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi,

Do you mean that you want to trigger NewWindow event when user clicks a link in the page? This is NOT what NewWindow event is for. NewWindow event is only triggered when your HTML explicitly requests a new window. For example, the following HTML code will NOT trigger NewWindow event:

Code: HTML/ASPX
<a href="http://www.google.com">Go to Google<a>


However the following HTML code WILL trigger NewWindow:

Code: HTML/ASPX
<a href="http://www.google.com" target="_blank">Go to Google<a>


Note the target="_blank" attribute.

Additionally, the following JavaScript code will also trigger NewWindow event:

Code: JavaScript
window.open("http://www.google.com");


Please feel free to let us know if you still have any questions.

Thanks!
chuarte
Posted: Friday, March 10, 2023 7:29:58 AM
Rank: Newbie
Groups: Member

Joined: 3/9/2023
Posts: 2
Thanks for the response. I don't think I have explained myself correctly, in my javascript I do call window.open, but when I click that button, in my C# it doesn't trigger the newWindow event. Even if i try to show a MessageBox.Show, it doesn't do anything. That's why I think that i'm not adding the event correctly on the code I pasted on the last post.
eo_support
Posted: Friday, March 10, 2023 9:22:05 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi,

The code you posted looks fine. So the problem must be in some other part of the code that is not posted. You can try to isolate the problem into a small test application and send the test application to us:

https://www.essentialobjects.com/forum/test_project.aspx

Once we have that we will be able to investigate further.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.