Live Chat Icon For mobile
Live Chat Icon

Can Blazor open a URL in a new tab using UriHelper NavigateTo?

Platform: Blazor| Category : General, Routing, JavaScript Interop

You have to use the JS interop to achieve this requirement.

public async Task NavigateToUrlAsync(string url, bool openInNewTab)
    {
        if (openInNewTab)
        {
            await JSRuntime.InvokeAsync<object>("open", url, "_blank");
        }
        else
        {
            this.UriHelper.NavigateTo(url);
        }
    }

Refer to this thread for more information.

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.