You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I only have one viewer on my dialog and I want to intercept new window request so that if it is a certain link it is suppressed and spawned in the default system browser.
But I don't understand how to interface the official sample code in the browser class that I am using.
Thank you for your help.
Importance
Moderate. My app's user experience is affected, but still usable.
Runtime Channel
Stable release (WebView2 Runtime)
Runtime Version
No response
SDK Version
No response
Framework
Win32
Operating System
Windows 11
OS Version
No response
Repro steps
Display html in your viewer that has a hyperlink using my class (on a dialog). Need to detect that link so I can disoplay it in system browser and not webview2.
Repros in Edge Browser
Not Applicable
Regression
No.
Last working version (if regression)
No response
The text was updated successfully, but these errors were encountered:
I seem to have this working the way I want it now:
// Register a handler for the NewWindowRequested event.CHECK_FAILURE(m_pImpl->m_webView->add_NewWindowRequested(
Callback<ICoreWebView2NewWindowRequestedEventHandler>(
[this](ICoreWebView2* sender, ICoreWebView2NewWindowRequestedEventArgs* args) {
// get the target Uri
LPWSTR sUri;
CHECK_FAILURE(args->get_Uri(&sUri));
// and if it was user initiated (e.g. click on an anchor tag)
BOOL bUserInit;
CHECK_FAILURE(args->get_IsUserInitiated(&bUserInit));
if (bUserInit && wcsncmp(sUri, L"file:", 5) != 0) {
// cancel default behaviour
args->put_Handled(TRUE);
// and open Uri in default browserShellExecute(0, 0, sUri, 0, 0, SW_SHOW);
}
return S_OK;
})
.Get(), nullptr));
It works as I want it to work. So file prefixed URLs are handled by WebView2 and others by a new browser instance. As long as my hyperlinks have a target property ...
What happened?
My webbrowser control class is based on this tutorial https://mariusbancila.ro/blog/2020/01/29/using-microsoft-edge-in-a-native-windows-desktop-app-part-2/ and not the official samples.
I show that code in a Stack Overflow answer: https://stackoverflow.com/a/68183783/2287576
I only have one viewer on my dialog and I want to intercept new window request so that if it is a certain link it is suppressed and spawned in the default system browser.
But I don't understand how to interface the official sample code in the browser class that I am using.
Thank you for your help.
Importance
Moderate. My app's user experience is affected, but still usable.
Runtime Channel
Stable release (WebView2 Runtime)
Runtime Version
No response
SDK Version
No response
Framework
Win32
Operating System
Windows 11
OS Version
No response
Repro steps
Display html in your viewer that has a hyperlink using my class (on a dialog). Need to detect that link so I can disoplay it in system browser and not webview2.
Repros in Edge Browser
Not Applicable
Regression
No.
Last working version (if regression)
No response
The text was updated successfully, but these errors were encountered: