title: JQuery Make sure web page is completely rendered before printing
body: <p>I have an odd situation, where some of the 6000 users of an online system are getting incomplete documents printed out.</p>
  
  <p>I have the following code at the bottom of the web page.</p>
  
  <pre><code>&lt;script type="text/javascript" defer="defer"&gt;
    window.onload = function(){@Html.Raw(ViewBag.StartupScript)};
  &lt;/script&gt;
  </code></pre>
  
  <p>and ViewBag.StartupScript is simply window.print();</p>
  
  <p>Most of the users get the full document with all the images loaded. But a handful get all the text, but one or more) of the images are missing.</p>
  
  <p>The images are at the bottom of the document.
  The images are on the same webserver (no cdn).
  We have to use IE or Edge for other legacy reasons.
  I cannot duplicate this at my workstation, I always see all the images.</p>
  
  <p>The only thing I can think of is that in some cases, the network, or individual PC is slow, and so is not receiving the whole document to print it, despite the document.ready function. However, from what I understand, window.onload only fires when all the images have been loaded.</p>
  
  <p>So, to keep this to questions not a discussion.
  Have I somehow misunderstood window.onload (and defer="defer", and the way they are used?</p>
  
  <p>Is there an alternative way I can guarantee that the document and all its images are downloaded before it is printed.</p>
  
  <p>And is there an easy way of proving my working theory that the print command is executed before the images are loaded?</p>
  
  <p>Just to muddy the waters, it appears that the PC's this does not work on are mainly Windows 7, not windows 10 running IE. I haven't proved this definitely yet, but it may be issue in the OS / browser implementation. </p>
  
  <p>To further update this (it still doesn't work properly). Some images are being aborted by ie, yet there is no consistency. Sometimes it is the first image that is aborted, other times on that page, the same image is loaded and a separate one is aborted. ((abort) in network tools. Googling this issue implies it is a mime type issue. but then I would expect it to reject or accept all mages, not act sporadically. Anyone got anymore ideas, if they are even still reading this?</p>