相关疑难解决方法(0)

我可以修改此Javascript来打印Div的图像吗?

我的页面布局中有一个div,我想要打印.我已经研究了一些如何执行此操作的示例代码,并提出以下建议:

<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.1.min.js" > </script> 
<script type="text/javascript">

function PrintElem(elem)
{
    Popup($(elem).text());
}

function Popup(data) 
{
    var mywindow = window.open('', 'print_div', 'height=400,width=600');
    mywindow.document.write('<html><head><title>Print Window</title>');
    mywindow.document.write('</head><body >');
    mywindow.document.write(data);
    mywindow.document.write('</body></html>');
    mywindow.document.close();
    mywindow.print();
    return true;
}

</script>
Run Code Online (Sandbox Code Playgroud)

然后在HTML的正文中我放置以下按钮:

<input type="button" value="Print Division" onclick="PrintElem('#print_div')" />
Run Code Online (Sandbox Code Playgroud)

这非常适合在页面上创建基于文本的内容的快速打印,但我需要它做的是打印出页面上显示的图像.我可以更改此脚本来执行此操作吗?

html javascript printing jquery image

0
推荐指数
1
解决办法
5521
查看次数

标签 统计

html ×1

image ×1

javascript ×1

jquery ×1

printing ×1