question

AnanthamS-6846 avatar image
0 Votes"
AnanthamS-6846 asked ScottWard-7727 commented

Blazor Open a page in a new Browser tab using navigation manager?

Could please advise me the way of open a page in new tab using Navigation manager and how to show pdf file in browser window?

dotnet-aspnet-core-blazor
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

miwan2-msft avatar image
1 Vote"
miwan2-msft answered miwan2-msft edited

Hi, @AnanthamS-6846 ,

The way of open a page in new tab

Try JSRuntime.InvokeAsync to open in new tab.

     await JSRuntime.InvokeAsync<object>("open", "navigate", "_blank");

53553-image.png



show pdf file in browser window

You can open pdf file directly via a tag.

     <a href="./HelloWorld.pdf" target="blank">Go to Hello</a>

53485-222.gif



If the answer doesn’t solve your issue, please provide more details of error that will help us track down what’s happening.
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Best Regards,
Michael Wang



image.png (99.8 KiB)
222.gif (263.6 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RamaMurthyVeera avatar image
0 Votes"
RamaMurthyVeera answered ScottWard-7727 commented

It's giving following error!!

blazor.webassembly.js:1 Uncaught (in promise) TypeError: Converting circular structure to JSON
--> starting at object with constructor 'Window'
--- property 'window' closes the circle
at JSON.stringify (<anonymous>)
at blazor.webassembly.js:1

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I was getting this error as well

change InvokeAsync<object> to InvokeVoidAsync and it seems to stop happening

strURL = "pages/mypage";
await JS.InvokeVoidAsync("open", strURL, "_blank");

2 Votes 2 ·