When building a Control Add-in for Business Central, you can define a JavaScript function that is callable from AL code. The CallJavaScript function in this example acts as an entrypoint that receives data passed from the AL side and updates the DOM.
To use this pattern, ensure your JavaScript file is included in your Control Add-in setup and that the function name matches the call made in your AL code.
function CallJavaScript(i, s, d, c) {
var div = document.querySelectorAll(".cb")[0];
div.innerText = ['Received from AL:', i, s, d, c].join(' ');
}