var elem = document.getElementById('mytest1'); // Simulate clicking on the specified element. triggerEvent( elem, 'click' ); /** * Trigger the specified event on the specified element. * @param {Object} elem the target element. * @param {String} event the type of the event (e.g. 'click'). */ function triggerEvent( elem, event ) { var clickEvent = new Event( event ); // Create the event. elem.dispatchEvent( clickEvent ); // Dispatch the event. }
Ссылка
Проблема, с которой вы столкнулись, заключается в следующей строке:
var theCanvas = document.getElementsById("GameCanvas");
Метод getElementsById()
не существует - он должен быть getElementById()
. Замените приведенную выше строку кода на следующую:
var theCanvas = document.getElementById("GameCanvas");
И ваш код должен работать.
Я думаю, вам нужно объявить встроенную функцию-обработчик
window.addEventListener("load", function(event) {
console.log("Tutte le risorse hanno terminato il caricamento!");
});
.