Answer the question
In order to leave comments, you need to log in
Can you explain why addEventListener is not working?
Hello!
I am copying information from one container to another and I need to track the moment when this process is completed completely.
I write like this:
// само копирование
document.getElementById('temp-content').innerHTML = document.getElementById('content').value;
// далее навешиваю обработчик который следит за контейнером
// и (теоретически) должен мне сообщить когда тот будет полностью готов
document.getElementById('temp-content').addEventListener("load", function() {
alert('Весь HTML-контент загружен в контейнер!');
});
load
, since it allows you to track the complete loading of all resources (including images). Answer the question
In order to leave comments, you need to log in
Because there is no such event.
HTML is inserted synchronously, no events are needed here.
To track the loading of images, after inserting, you need to select all the images in the desired element, and hang a handler on each.
At the same time, you need to take into account that some image may not load, and some may freeze in the loading state.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question