Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Links with target=_blank ignores default browser? #105

Closed
connorjburton opened this issue Apr 27, 2018 · 3 comments
Closed

Links with target=_blank ignores default browser? #105

connorjburton opened this issue Apr 27, 2018 · 3 comments

Comments

@connorjburton
Copy link

It seems if you have a link without target _blank it will open the link in your default browser

If you have a link with target _blank it will open the link in IE

Could you confirm this? Thanks

@jimbobmcgee
Copy link
Contributor

This may be a subtlety of the WebBrowser control used to render HTML content. The WebBrowser uses IE internally, so it stands to reason that telling it to open a new window (i.e. target="_blank") would open a new IE window.

Since Papercut already handles (and cancels) the WebBrowser control's Navigating event, so it can call Process.Start(theUrl) to open your default browser, I suspect that the IE's decision to make the new window happens before the decision to navigate, so that cancellation never happens.

In the old .NET Forms WebBrowser, there was a NewWindow event that could be coerced to cancel opening a new window (browser.NewWindow += (s, e) => { e.Cancel = true; };). However, it looks like that event never made it into the WPF version of the control.

Instead, an example in the MSDN documentation suggests that you can get a reference to the underlying IE COM object and hook NewWindow2 to the same effect. It looks like Papercut does something fairly similar to prevent showing script errors.

https://docs.microsoft.com/en-us/dotnet/api/system.windows.controls.webbrowser?view=netframework-4.7.2

@stale
Copy link

stale bot commented Feb 6, 2019

Aloha! I'm ScissorBot ✂️ -- the bot in charge of keeping the issues tidy. It looks like this issue is stale due to lack of activity. Unfortunately, I'll be closing it if there is no further activity. 😞 Please contribute to the issue to keep it open. Thanks!

@stale stale bot added the wontfix label Feb 6, 2019
@Jaben Jaben removed the wontfix label Feb 11, 2019
@Jaben
Copy link
Member

Jaben commented Feb 11, 2019

I'll investigate a bit more

@Jaben Jaben closed this as completed in 44479c9 Feb 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants