JavaScript: Stop while loop when an event occurs
<p>I want a while loop to stop when the "load" event occurs.</p>

<p>This executes a while loop after the event occurs:</p>

<pre><code>window.addEventListener("load", function() {
    while (...) {...}
});
</code></pre>

<p>I wish to do this in pure JavaScript (not using jQuery or any other library).</p>

<p>("load" event: the page is fully loaded; <code>document.readyState == "complete"</code>: the page is not fully loaded.)</p>