Aspnetcore: UriHelper NavigateTo new tab

Created on 21 Mar 2019  路  3Comments  路  Source: dotnet/aspnetcore

Hello,

is it somehow possible (in Blazor) to programatically open a url in new tab?

Best regards,
Thomas

area-blazor question

Most helpful comment

Just in case someone else come accross this post...

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


All 3 comments

Thanks for contacting us, @TFTomSun.
@SteveSandersonMS is this something possible with pure Blazor, or should this be achieved with JSInterop for now?

You'll need to use JS interop for this.

Just in case someone else come accross this post...

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


Was this page helpful?
0 / 5 - 0 ratings