How to print the contents of a DIV in a way that includes pictures?
P粉561438407
P粉561438407 2023-09-10 18:24:42
0
1
525

I have this code. Prints the contents of the DIV by its ID, but omits one picture. I hope you will support me and tell me how to include this image. (The picture is also inside the DIV)

impresion = DIV to print

function printDiv(impresion) {
     var contenido= document.getElementById(impresion).innerHTML;
     var contenidoOriginal= document.body.innerHTML;


     document.body.innerHTML = contenido;

     window.print();

     document.body.innerHTML = contenidoOriginal;
}

I tried many methods but none of them worked

P粉561438407
P粉561438407

reply all(1)
P粉270891688

Here is a simple solution using only CSS:

@media print {
  body * {
    visibility: hidden;
  }
  #impresion, #impresion * {
    visibility: visible;
  }
  #impresion {
    position: absolute;
    left: 0;
    top: 0;
  }
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template