Live Chat Icon For mobile
Live Chat Icon

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

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.