参考这个链接 http://www.w3schools.com/jsref/met_win_print.asp and this http://www.javascriptkit.com/howto/newtech2.shtml,我使用 javascript 打印报告
<!DOCTYPE html>
<html>
<head>
<script>
function printpage()
{
var data = 'Sample Report<br />Sample Report<br />Sample Report<br />';
var data = data+'<br/><button onclick="window.print()">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();
}
</script>
</head>
<body>
<input type="button" value="Print Preview" onclick="printpage()" />
</body>
</html>
但打印后,打印按钮仍然保留在硬拷贝上。那么如何利用上述功能在打印时隐藏硬拷贝中的打印按钮呢?
给你的按钮一个类,例如class="noprint"
。然后将打印媒体的样式表添加到 CSS 中:
@media print {
/* style sheet for print goes here */
.noprint {
visibility: hidden;
}
}
细节:http://www.w3.org/TR/CSS2/media.html http://www.w3.org/TR/CSS2/media.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)