• Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

window.print() loses the image

  • Thread starter Deleted member 2829
  • Start date

Deleted member 2829

I have a strange issue with Chrome.

When I create a window with html that contains an image, the image is displayed ok. But then if I do window.print() the image disappears from the new window, and consequently is not printed. Note, this only happens when my CacheKiller extension is active. Of course I don't normally have Cache Killer running, so it's not much of a problem, but I'd like to understand this. My complete code :

const inner=`<html>
             <div style='border:3px blue solid;width:300px' >
             <img src='edward.jpg' style='width:100%'>
             <div style='font-size:32px;color:red;'>Nice !!</div>

function test(print)
    var w = window.open("", "Print", "width=800,height=800");
    if (print)
<body     onload="divleft.innerHTML = inner;">
<div      id="divleft"        ></div><br>
<button   onclick="test(false)"  >Test</button>&nbsp;&nbsp;&nbsp;
<button   onclick="test(true)"   >Test with print</button>

The used image is attached. I guess what I need is a way to tell the window, or its document, to (re)load external content like images, as it's evidently not doing it by itself. But I can't find anything to that effect. Any ideas much appreciated.


  • edward.jpg
    69.1 KB · Views: 0

New Threads

Buy us a coffee!

Top Bottom