Live Chat Icon For mobile
Live Chat Icon

How do I call a JavaScript method with parameters in Blazor WebAssembly?

Platform: Blazor| Category : General, JavaScript Interop

You call a JavaScript function with parameters using JavaScript Interop.


JsRuntime.InvokeVoidAsync("JS method name", "parameters");

Follow this code to call a JavaScript method with parameters in Blazor WebAssembly


@page "/"
@inject IJSRuntime JsRuntime

@code {
    protected override async void OnInitialized()
        string content = "JavaScript function called with parameter";
        await JsRuntime.InvokeVoidAsync("jsFunction", content);


      . . . 
      . . . 

        function jsFunction(value) {
            // Parameter value has been passed here.
</body >

Refer to this documentation for more information.

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.