I am trying to print an ASP.NET Image using the example here.
When I use the above example for a div, it works, but I can’t adapt it to print anything else. How can I get it to print an Image? Do I wrap the Image in a div and change the “.text()” part in the script to something else?
Because you’re passing a wrong parameter to the printing function. Printing something in JavaScript is as easy as calling
window.print();method. To test it, simply use developer tools of your browser and write into its console:Now, when you want to print something specific, you have two ways:
Now, what you can do is to write your own function:
and you can also see this function in action here.
Just let the browser open popup, and also note that I only pass the
srcvalue of the image element to the new window.