javascript 如何实现打印功能
2个回答
展开全部
打印整个页面 用document.execCommand("Print");
打印单张图片:
<script type="text/javascript">
function printpic(picurl,width,height){
var x=window.open("","gainover","width=400,height=300,top=0,left=0");
x.document.write("<img src='"+picurl+"' width='"+width+"' height='"+height+"'></img>");
x.document.execCommand("Print");
}
printpic("images/about_01.jpg",300,400);
</script>
打印单张图片:
<script type="text/javascript">
function printpic(picurl,width,height){
var x=window.open("","gainover","width=400,height=300,top=0,left=0");
x.document.write("<img src='"+picurl+"' width='"+width+"' height='"+height+"'></img>");
x.document.execCommand("Print");
}
printpic("images/about_01.jpg",300,400);
</script>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询