Reputation:
I have tried using scripts like...
window.addEventListener('hashchange', function()
{
alert(1);
});
and...
window.addEventListener('popstate', function()
{
alert(1);
});
... without luck.
Note that initialization is done properly, other scripts work, navigation is fine, and this is WinForms
.
So, how to detect WebView2 back and forward events?
Much appreciated.
Upvotes: 1
Views: 938
Reputation:
@RezaAghaei provided the answer above.
Subscribing to the CoreWebView2.HistoryChanged
event does the trick.
Note that, naturally, this must be done after CoreWebView2
has been initialized.
Subscribing to the CoreWebView2.SourceChanged
event also works.
Upvotes: 1