I had a problem with the content generated by Javascript:
I am using the event of onload()my html page to load HTML code from the server and enter it on the page. Since it is already html, I use the property innerHtmlfor the nodes that I want to fill with content.
As soon as I entered the HTML, I call the handmade function adjustHeights(), which normalizes the height of the elements that I created so that they all correspond to the height of the highest element.
All this works fine if the code inside innerHtmldoes not contain any image or other media that takes time to download (in particular, video), because it adjustHeights()is called between the code and the end of the download, the time of the image / video / etc.
Is there a way to wait for each item to be loaded before the call adjustHeights()? I already tried the property document.onreadystatechange, but the state is already completed when I start to enter the code.
If possible, I would prefer not to use hourly calls on adjustHeights().
To make the example clearer:
var mylist = document.getElementById('mycontent');
var li;
for (var i = 0; i < res.length; i++)
{
li = document.create('li');
li.innerHTML=res[i];
mylist.appendChild(li);
}
adjustHeights();
source
share