打印网页,去掉标题,页码,网页地址等
我目前正在做一个网页打印功能,即把网页上显示的表格打印出来。
打印功能已经实现,就是很简单的那个函数,但这样出来的效果,左上角有网页的标题,右上角有页码,最下面则是 网页地址 和日期。
目前只想要 表格 和里面的内容,请问应该怎么写代码控制,不修改打印机的设置,网页显示后,立即执行打印即为所得!??
------解决方案-------------------- <html>
<head>
<script language= "javascript ">
function printIt() {
htmlcode=window.document.body.innerHTML;
sprnstr= " <!--startprint--> ";
eprnstr= " <!--endprint--> ";
var prnhtml=htmlcode.substr(htmlcode.indexOf(sprnstr)+17);
prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));
window.document.body.innerHTML=prnhtml;
window.print();
window.document.body.innerHTML=htmlcode;
}
</script>
</head>
<body>
不想打印内容 <br>
<!--startprint-->
要打印内容
<!--endprint-->
<br>
不想打印内容 <br>
<a href= "javascript:printIt() "> 打印 </a>
</body>
</html>
昨天刚找到的,原帖地址没有记住~~~
------解决方案--------------------要打印的部分 放到iframe里面 比如一篇文章或者新闻
设置iframe的样式 基本看不出来文章是放到iframe里面的
然后调用iframe的print直接打印就OK
------解决方案--------------------控制 "纵打 "、 横打”和“页面的边距。
(1) <script defer>
function SetPrintSettings() {
// -- advanced features
factory.printing.SetMarginMeasure(2) // measure margins in inches
factory.SetPageRange(false, 1, 3) // need pages from 1 to 3
factory.printing.printer = "HP DeskJet 870C "
factory.printing.copies = 2
factory.printing.collate = true
factory.printing.paperSize = "A4 "
factory.printing.paperSource = "Manual feed "
// -- basic features
factory.printing.header = "This is MeadCo "
factory.printing.footer = "Advanced Printing by scriptX "
factory.printing.portrait = false
factory.printing.leftMargin = 1.0
factory.printing.topMargin = 1.0
factory.printing.rightMargin = 1.0
factory.printing.bottomMargin = 1.0
}
</script>
(2)
<script language= "javascript ">
function printsetup(){
// 打印页面设置
wb.execwb(8,1);
}
function printpreview(){
// 打印页面预览
wb.execwb(7,1);
}
function printit()
{
if (confirm( ' '确定打印吗? ' ')) {
wb.execwb(6,6)
}
}
</script>
</head>
<body>
<OBJECT classid= "CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 "
height=0 id=wb name=wb width=0> </OBJECT>
<input type=button name=button_print value= "打印 "
onclick= "javascript:printit() ">
<input type=button name=button_setup value= "打印页面设置 "
onclick= "javascript:printsetup(); ">
<input type=button name=button_show value= "打印预览 "
onclick= "javascript:printpreview(); ">
<input type=button name=button_fh value= "关闭 "
onclick= "javascript:window.close(); ">
------解决方案--------------------支持一下楼主!
可以试试看报表工具
------解决方案--------------------……
<script language= "JavaScript ">