Is it possible in Blazor to open a URL in new tab programmatically?

We can make use of JS Interop to open a URL in new tab.

public async Task NavTo(string url, bool isNewTab)
{
       if (isNewTab)
        {
              await JSRuntime.InvokeAsync<object>("open", url, "_blank");
        }
        else
        {
                 NavManager.NavigateTo(url);
        }
}

Share with

Related FAQs

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

Please submit your question and answer.