相关文章推荐
会搭讪的卤蛋  ·  Notify Update·  1 年前    · 
坏坏的柿子  ·  react 动态设置title-掘金·  1 年前    · 

You can open pdf file directly via a tag.

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

------
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

I try to open three tabs but only open the first.

    await JSRuntime.InvokeVoidAsync("open", "https://google.com", "_blank");  
    await JSRuntime.InvokeVoidAsync("open", "https://bing.com", "_blank");  
    await JSRuntime.InvokeVoidAsync("open", "https://yahoo.com", "_blank");  

How can I open three at the same time?

Thank you,

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

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");

Confirmed. I got the same error when using this. But it is interessting to see that the new tab is open and shows the correct page. But after successfully open the tab, the task is throwing an error due to the task has cancelled.

Edit: I tried to add an CancellationToken.Null as a parameter and it seems to work without exception.

await _js.InvokeAsync<object>("open", CancellationToken.None, url);

I am very new to this Blazor Server framework. But I have been having the same 'JS Converting circular structure ' until I noticed that the two calls were slightly different: await JSRuntime.InvokeAsync<object>("open", url, "_blank"); fails await JSRuntime.InvokeVoidAsync("open", url, "_blank"); solves the problem.