Live Chat Icon For mobile
Live Chat Icon

I could not find the property of window when calling the JavaScript method in Blazor using JS interop.

You have to refer to the JavaScript method implemented JS (external-script.js) file in index.html properly and then call the function from .NET using IJSRuntime.



    <script src="_framework/blazor.webassembly.js"></script>
    <script src="external-script.js"></script>


window.methods = {
    print: function (message) {
        return "from js " + message


@inject IJSRuntime JSRuntime

@code {
  private async void PrintMessage()
    Console.WriteLine(await JSRuntime.InvokeAsync<string>("methods.print", "here is the message"));


Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.