Refer to script from within document's body (HTML)?

I have an HTML menu with a form containing radio buttons, placed in the body of my document. I put it there by means of document.body.appendChild(…some HTML file).

Now I wish to access a certain entity and script from within my HTML menu. I would like to write onClick=“something” in my input tag. The question is, how can I access entities and scripts from here? I can see, using Chrome’s Developer tools, that the scripts are defined in the header. I just don’t know how to access them.

Ok, I found an earlier answer that does seem to work, although not pretty, here. Is this still the suggested method?

There are many ways. But it is not flexible and good to define javascript right in your html. It is better to attach events and JS logic outside of HTML. Then it will be easier to manage it, and will allow you to access context of entity script which has all necessary functionality and app pointer to find other entities/scripts, etc.
Try out this example:

1 Like