我们在开发和设计网页时,经常要使用到打印网页内容的按钮。所以,就需要用到打印网页的代码,这里,我从网上收集到了5个,发布出来与大家分享。 一、控制"纵打"、 "横打"和"页面的边距"。
(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:8856fArray61-340a-11d0-aArray6b-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();">
------------------------------------------------ 关于这个组件还有其他的用法,列举如下: webbrowser.execwb(1,1) 打开 web.execwb(2,1) 关闭现在所有的ie窗口,并打开一个新窗口 web.execwb(4,1) 保存网页 web.execwb(6,1) 打印 web.execwb(7,1) 打印预览 web.execwb(8,1) 打印页面设置 web.execwb(10,1) 查看页面属性 web.execwb(15,1) 好像是撤销,有待确认 web.execwb(17,1) 全选 web.execwb(22,1) 刷新 web.execwb(45,1) 关闭窗体无提示
|