javascriptwidgetblazor

How to add widget script to Blazor page


I need to add widget script to my Blazor project.

If I'm adding script to _Host.cshtml this widget runs on all project pages. But I need to run it only on selected pages.

I can't insert

    <script src="//code-ya.jivosite.com/widget/kiMhndUDCT" async></script>

to .razor component.

How can i do that with JSRuntime?

Thanks!


Solution

  • Here is what I would do:

    1. Create a Component: Blazor Components
    2. Within that Component, use JS Interop
    3. Add this "Widget Blazor Componenet" that you just made to your pages you need.