New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_framework/blazor.server.js disable javascript HTMLCollection-array access #1785

UrielMhezzek opened this Issue Feb 9, 2019 · 3 comments


None yet
3 participants
Copy link

UrielMhezzek commented Feb 9, 2019

I wan't add a event to html-Element by use this JavaScript-Code.

var classnameasdf = document.getElementsByClassName("jsAddOnKeyEvent");
//for (var i = 0; i < classnameasdf.length; i++) {
//    classname[i].addEventListener('click', myFunction, false);

My Console wrote this

key.js:20 HTMLCollection(1)
key.js:21 null

My Index.html

    <script src="javascript/key.js"></script>
    <script src="_framework/blazor.server.js"></script>

My Component

@page "/test"
<p>TestString: @TestString</p>
<input bind="TestString" class="jsAddOnKeyEvent" />a

I think there is something in blazor.server.js that prevents me from getting access to the array, a HTMLCollection to be precise.

@UrielMhezzek UrielMhezzek changed the title _framework/blazor.server.js disable javascript array access _framework/blazor.server.js disable javascript HTMLCollection-array access Feb 9, 2019


This comment has been minimized.

Copy link

xclud commented Feb 9, 2019

You should run the script after blazor load finishes. Unfortunately blazor does not fire any events for us. So what you want to do currently has no solution.

Maybe a trick works for you. Put all you js code in a function and use setTimeout to call your function after 3 seconds. This is not a good solution because it may take longer than 3 seconds for the client to load.


This comment has been minimized.

Copy link

UrielMhezzek commented Feb 9, 2019

Thank you. This help. I hope blazor fix the problem.


This comment has been minimized.

Copy link

danroth27 commented Feb 10, 2019

This issue was moved to aspnet/AspNetCore#7430

@aspnet aspnet locked and limited conversation to collaborators Feb 10, 2019

@danroth27 danroth27 closed this Feb 10, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.