我們在開發(fā)和設(shè)計網(wǎng)頁時,經(jīng)常要使用到打印網(wǎng)頁內(nèi)容的按鈕。所以,就需要用到打印網(wǎng)頁的代碼,這里,我從網(wǎng)上收集到了5個,發(fā)布出來與大家分享。 一、控制"縱打"、 "橫打"和"頁面的邊距"。
。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(){ // 打印頁面設(shè)置 wb.execwb(8,1); } function printpreview(){ // 打印頁面預(yù)覽 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="打印頁面設(shè)置"
onclick="javascript:printsetup();"> <input type=button name=button_show value="打印預(yù)覽"
onclick="javascript:printpreview();"> <input type=button name=button_fh value="關(guān)閉"
onclick="javascript:window.close();">
------------------------------------------------ 關(guān)于這個組件還有其他的用法,列舉如下: webbrowser.execwb(1,1) 打開 web.execwb(2,1) 關(guān)閉現(xiàn)在所有的ie窗口,并打開一個新窗口 web.execwb(4,1) 保存網(wǎng)頁 web.execwb(6,1) 打印 web.execwb(7,1) 打印預(yù)覽 web.execwb(8,1) 打印頁面設(shè)置 web.execwb(10,1) 查看頁面屬性 web.execwb(15,1) 好像是撤銷,有待確認 web.execwb(17,1) 全選 web.execwb(22,1) 刷新 web.execwb(45,1) 關(guān)閉窗體無提示
|