I have a Blazor Server web app; .NET 5.
I am running into frustrations related to navigating between pages in my web app:
NavigationManager.NavigateTo(uri, true)
, I am unable to open links using my scroll click (which would open the link in a new browser tab if I were to use href="uri"
instead). It opens a new tab, but loads the same page I was already on.href="uri"
instead, the scroll-click works. However, it introduces a new problem: with a 'normal' left-click, the new page loads but retains the scroll position of the previous page in a mobile browser (I have tested with mobile Safari, as well as the mobile emulator in Chrome).I need to be able to scroll-click into a new tab, as well as have a new page load without retaining the previous page's scroll position. Any tips?
Assuming that you are using the onclick
event:
The onclick
event does not listen for the scroll wheel click. To fix this just use the onmousedown
event instead:
<button class="btn btn-dark" @onmousedown="OnClick">Test</button>
@code {
private void OnClick()
{
NavigationManager.NavigateTo("/counter", true);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With