在网站上打印图像 [英] Print image on website

查看:128
本文介绍了在网站上打印图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站上显示的图片缩小了。我希望能够单击该图像,然后打开全尺寸图像并将其打印出来。我在网上看到了一些例子,但它们都是指打印出正在显示的图像。我需要打开并打印全尺寸图像才能清晰易读。提前致谢

I have an image displayed on my website in a reduced size. I would like to be able to click that image, and it open the full size image and print it out. I've seen a few examples online, but they all refer to printing out the one image being displayed. I would need the full size image to be opened and print in order to be legible. Thanks in advance

推荐答案

您可以将较大的图像隐藏在另一个div中,然后打印该图像,如

You could hide the larger image inside another div and print that image instead, like

<script type="text/javascript">

function printDiv(divName) {
     var printContents = document.getElementById(divName).innerHTML;
     var originalContents = document.body.innerHTML;

     document.body.innerHTML = printContents;

     window.print();

     document.body.innerHTML = originalContents;
}

</script>

<img src="images/smaller-img.jpg" />

<a href="#" onClick="printDiv('largeimg')">Print</a>

<div  id="largeimg" style="display:none;">
<img src="images/larger-img.jpg">
</div> 

这篇关于在网站上打印图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆