WEB开发网
开发学院网页设计JavaScript js 控制网页打印大全 阅读

js 控制网页打印大全

 2012-12-14 15:08:49 来源:WEB开发网   
核心提示://factory.printing.SetMarginMeasure(2); // measure margins in inches //factory.SetPageRange(false, 1, 3);// need pages from 1 to 3 //factory.printing.printer

//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"

var header = (headerText==null||headerText=="")?'默认页眉':headerText;

var footer = (footerText==null||footerText=="")?'默认页角':footerText;

factory.printing.header = "&b"+header+"&b" ;

factory.printing.footer = "&b"+footer;

factory.printing.portrait = true;

factory.printing.leftMargin =10.00;

factory.printing.topMargin =10.00;

factory.printing.rightMargin =10.00;

factory.printing.bottomMargin =10.00;

}


例子

引用:

<html>
<head>
<meta http-equiv="imagetoolbar" c>
<script language="javascript" src="print.js"></script>
<style media="print">
.Noprint {DISPLAY: none;}
</style>
<title>打印测试</title>
</head>
<OBJECT id="factory" style="DISPLAY: none" codeBase="smsx.cab#VVersion=6,3,435,20" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" viewastext></OBJECT>

<script defer>
function window.onload() {
setPrintBase('页眉','页脚');
}
</script>
<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0">
<center class="Noprint">
<input type=button value="打印" >
<input type=button value="页面设置" >
<input type=button value="打印预览" >
<input type="button" value="关闭" >
</center>
<center>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td align="center"><b>内容</b></td></tr>
</table>
</center>
</body>
</html>

(五)打印背景
默认情况下,使用IE浏览器打印网页时,不打印网页背景。如果需要打印网页背景,可以采用如下的方法设置:
1. 启动IE浏览器。
2. 选择【工具】菜单中的【Internet选项】菜单项,打开【Internet选项】对话框。
3. 打开【高级】选项卡,在【打印】选区中选择【打印背景颜色和图像】复选框。
4. 单击【确定】按钮,关闭对话框。

(六)如何用IE打印网页


Internet Explorer(简称IE)5.0以上版本强大的打印及打印预览功能。本文就向大家介绍如何用IE来打印网页。(谁?谁?谁在扔西红柿?下面一片嘘声:这还用得着你讲呀?!)咳咳咳,是的是的,在IE中打印网页实在是太简单不过了。只需点一下工具栏上“打印”按钮就可将当前网页打印出来。如下图所示:

上一页  1 2 3 4  下一页

Tags:js 控制 网页

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接