當前位置:成語大全網 - 書法字典 - Js印刷詞典

Js印刷詞典

總結JS的打印方法,以供參考。

1.用JS自帶功能打印

直接呼叫

Java代碼復制代碼

1.& lta href =“JavaScript:window . print();“& gt打印

& lta href =“JavaScript:window . print();“& gt打印

二。。IEWebBrowser組件

介紹

/default.aspx?scid=kb%3BEN-US%3BQ267240#top

/kb/q 247671/#應用於

Java代碼復制代碼

1.& ltOBJECT classid = CLSID:8856 f 961-340 a-11d 0-A96B-00c 04 FD 705 a 2 height = 0 id = WebBrowser width = 0 & gt;& lt/OBJECT & gt;

2.& ltinput name = button click = document . all . webbrowser . exec WB(1,1)Type = button value = open》

3.& ltinput name = button click = document . all . webbrowser . exec WB(2,1)type = button value = close all》

4.& ltinput name = button click = document . all . webbrowser . execb(4,1)type = button value =另存為》

5.& ltinput name = button click = document . all . webbrowser . exec WB(6,1)type = button value = print》

6.& ltinput name = button click = document . all . webbrowser . execb(6,6)type = button value =直接打印》

7.& ltinput name = button click = document . all . webbrowser . exec WB(7,1)type = button value = print preview》

8.& ltinput name = button click = document . all . webbrowser . execb(8,1)type = button value = page setup》

9.& ltinput name = button click = document . all . webbrowser . exec WB(10,1)Type = button value = attribute》

10.& ltinput name = button click = document . All . webbrowser . exec WB(17,1)Type = button value = Select All》

11.& ltinput name = button click = document . all . webbrowser . execb(22,1)type = button value = refresh》

12.& ltinput name = button click = document . all . webbrowser . exec WB(45,1)type = button value = close》

& ltOBJECT classid = CLSID:8856 f 961-340 a-11d 0-A96B-00c 04 FD 705 a 2 height = 0 id = WebBrowser width = 0 & gt;& lt/OBJECT & gt;

& ltinput name = button click = document . all . webbrowser . exec WB(1,1)type = button value = open》

& ltinput name = button click = document . all . webbrowser . exec WB(2,1)type = button value = close all》

& ltinput name = button click = document . all . webbrowser . execb(4,1)type = button value =另存為》

& ltinput name = button click = document . all . webbrowser . exec WB(6,1)type = button value = print》

& ltinput name = button click = document . all . webbrowser . execb(6,6)type = button value =直接打印》

& ltinput name = button click = document . all . webbrowser . exec WB(7,1)type = button value = print preview》

& ltinput name = button click = document . all . webbrowser . execb(8,1)type = button value = page setup》

& ltinput name = button click = document . all . webbrowser . exec WB(10,1)Type = button value = attribute》

& ltinput name = button click = document . All . webbrowser . exec WB(17,1)Type = button value = Select All》

& ltinput name = button click = document . all . webbrowser . execb(22,1)type = button value = refresh》

& ltinput name = button click = document . all . webbrowser . exec WB(45,1)type = button value = close》

3.使用ScriptX.cab控件

1.下載ScriptX.cab控件。

官方網站/scriptx/index.asp

2.使用object元素修改codebase和classid的值。

在這裏調用控件ScriptX.cab。

Java代碼復制代碼

1.& ltOBJECT id =“factory“style =“DISPLAY:none“code base =“$ { root URL } js/smsx . cab # VVersion = 6,3,435,20“classid =“clsid:1663 ed 61-23eb-11 D2-b92f-008048 FDD 814“viewstext & gt。& lt/OBJECT & gt;

& ltOBJECT id =“factory“style =“DISPLAY:none“code base =“$ { root URL } js/smsx . cab # VVersion = 6,3,435,20“classid =“clsid:1663 ed 61-23eb-11 D2-b92f-008048 FDD 814“viewstext & gt。& lt/OBJECT & gt;

此代碼用於加載cab文件。clsid和codebase必須與您下載的cab中的信息相對應,否則組件將無法正確加載。這兩項並不難找到,只要打開用winrar下載的cab文件,然後找到擴展名為的文件即可。inf,然後打開它,就可以看到了。

3.調用控制腳本

Print.js文件

Java代碼復制代碼

1.函數setPrintBase(header text,footerText,root URL ){

2.

3.//-高級功能,從未使用過,有待確認。

4.

5.//factory . printing . setmarginmeasure(2);//以英寸為單位測量邊距

6.

7.//工廠。SetPageRange(false,1,3);//需要從1到3的頁面

8.

9.//factory . printing . printer =“HP DeskJet 870 c“;

10.

11.//factory . printing . copies = 2;

12.

13.//factory . printing . collate = true;

14.

15.//factory . printing . papersize =“A4“;

16.

17.//factory . printing . paper source =“手動送紙“

18.

19.var header =(header text = = null | | header text = =““)?“default header”:header text;

20.

21.var footer =(footer text = = null | | footer text = =““)?“默認頁面角度”:footerText

22.

23.factory . printing . header =“& amp;b“+header+“& amp;b“;

24.

25.factory . printing . footer =“& amp;b“+頁腳;

26.

27.factory . printing . portrait = true;

28.

29.factory . printing . left margin = 10.00;

30.

31.factory . printing . top margin = 10.00;

32.

33.factory . printing . right margin = 10.00;

34.

35.factory . printing . bottom margin = 10.00;

36.

37.}

函數setPrintBase(header text,footerText,root URL ){

//-高級功能,從未使用過,有待確認。

//factory . printing . setmarginmeasure(2);//以英寸為單位測量邊距

//工廠。SetPageRange(false,1,3);//需要從1到3的頁面

//factory . printing . printer =“HP DeskJet 870 c“;

//factory . printing . copies = 2;

//factory . printing . collate = true;

//factory . printing . papersize =“A4“;

//factory . printing . paper source =“手動送紙“

var header =(header text = = null | | header text = =““)?“default header”:header text;

var footer =(footer text = = null | | footer text = =““)?“默認頁面角度”:footerText

factory . printing . header =“& amp;b“+header+“& amp;b“;

factory . printing . footer =“& amp;b“+頁腳;

factory . printing . portrait = true;

factory . printing . left margin = 10.00;

factory . printing . top margin = 10.00;

factory . printing . right margin = 10.00;

factory . printing . bottom margin = 10.00;

}

例子

Java代碼復制代碼

1.& lt%@頁content type =“text/html;charset = GBK“% & gt;

2.

3.& lthtml & gt

4.& lthead & gt

5.& ltmeta/afei 0211/blog/item/20523955 ca 8 beb 2c b 745 AE 98 . html

/hong 1125/blog/item/0152 bcfd 84 ce 1e 1008244 d5c . html

網絡環境。

/fly金魚/archive/2004/08/17/77208 . aspx