在硬拷贝打印按钮 [英] Print button in hard copy

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

问题描述

我在保存在这个小提琴 JavaScript的打印脚本。但我无法从硬拷贝删除打印按钮。是否有任何其他的方法来取出打印按钮?下面的脚本所示:

 函数的PrintPage()
{
VAR数据='样本报告< BR />示例报告< BR />示例报告< BR />';
    VAR数据=数据+'< BR /><按钮的onclick =window.print()级=NOPRINT>打印报告< /按钮>';
    为mywindow = window.open('','','宽= 800,高度= 600');
    myWindow.innerWidth = screen.width;
    myWindow.innerHeight = screen.height;
    myWindow.screenX = 0;
    myWindow.screenY = 0;
    myWindow.document.write(数据);
    myWindow.focus();
}

和HTML是

 <输入类型=按钮值=打印preVIEW的onclick =的PrintPage()/>


解决方案

样式声明添加到preVIEW窗口:

函数的PrintPage(){
    VAR数据='样本报告< BR />示例报告< BR />示例报告< BR />';
    数据+ ='< BR /><按钮的onclick =window.print()级=NOPRINT>打印报告< /按钮>';
    数据+ ='<风格类型=文/ CSS媒体=打印> .noprint {能见度:隐藏;}< /风格与GT;';
    为mywindow = window.open('','','宽= 800,高度= 600');
    myWindow.innerWidth = screen.width;
    myWindow.innerHeight = screen.height;
    myWindow.screenX = 0;
    myWindow.screenY = 0;
    myWindow.document.body.innerHTML =数据;
    myWindow.focus();
}

http://jsfiddle.net/4d3jj/2/

I have a printing script in javascript saved in this fiddle. But I unable to remove the print button from the hardcopy. Is there any other methods to remove the print button? The script is given below:

function printpage()
{
var data = 'Sample Report<br />Sample Report<br />Sample Report<br />';
    var data = data+'<br/><button onclick="window.print()"  class="noprint">Print the Report</button>';       
    myWindow=window.open('','','width=800,height=600');
    myWindow.innerWidth = screen.width;
    myWindow.innerHeight = screen.height;
    myWindow.screenX = 0;
    myWindow.screenY = 0;
    myWindow.document.write(data);
    myWindow.focus();
}

and html is

<input type="button" value="Print Preview" onclick="printpage()" />

解决方案

Add the style declaration to preview window:

function printpage() {
    var data = 'Sample Report<br />Sample Report<br />Sample Report<br />';
    data += '<br/><button onclick="window.print()"  class="noprint">Print the Report</button>';
    data += '<style type="text/css" media="print"> .noprint {visibility: hidden;} </style>';
    myWindow = window.open('', '', 'width=800,height=600');
    myWindow.innerWidth = screen.width;
    myWindow.innerHeight = screen.height;
    myWindow.screenX = 0;
    myWindow.screenY = 0;
    myWindow.document.body.innerHTML = data;
    myWindow.focus();
}

http://jsfiddle.net/4d3jj/2/

这篇关于在硬拷贝打印按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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