導航:首頁 > 編程語言 > js循環列印小星星

js循環列印小星星

發布時間:2023-03-27 20:45:00

js如何循環保存數字到列表中

js中使用nodemon就可以自動循環保存數字。具體操作:
1、初始化yarninit。
2、安裝nodemonyarnaddnodemondev。
3、創建一個空的js文件,裡面只有一行簡單的列印輸出consolelog(「111」)。
4、運行yarnnodemones6Testjs。
5、當我們再次修改內容,保存之後,控制台就會自動循環保存數字。

⑵ js中怎樣列印結果

一般是用alert();來彈出顯示變數的值,js中沒有控制台列印的說法,或者你可以把變數的值放在html標簽中去顯示,但是這種方式沒有alert();來的直接,希望可以幫助到你,望採納,謝謝!

⑶ js列印問題,急!!!!!

對JS的列印方法總結一下,方便日後查閱。

一.用JS自帶函數列印

直接調用
java代碼 復制代碼

1. <a href="javascript:window.print();">列印</a>

<a href="javascript:window.print();">列印</a>

二.IEWebBrowser組件

介紹

http://support.microsoft.com/default.aspx?scid=kb%3BEN-US%3BQ267240#top
http://support.microsoft.com/kb/q247671/#appliesto

Java代碼 復制代碼

1. <OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0></OBJECT>
2. <input name=Button onClick=document.all.WebBrowser.ExecWB(1,1) type=button value=打開>
3. <input name=Button onClick=document.all.WebBrowser.ExecWB(2,1) type=button value=關閉所有>
4. <input name=Button onClick=document.all.WebBrowser.ExecWB(4,1) type=button value=另存為>
5. <input name=Button onClick=document.all.WebBrowser.ExecWB(6,1) type=button value=列印>
6. <input name=Button onClick=document.all.WebBrowser.ExecWB(6,6) type=button value=直接列印>
7. <input name=Button onClick=document.all.WebBrowser.ExecWB(7,1) type=button value=列印預覽>
8. <input name=Button onClick=document.all.WebBrowser.ExecWB(8,1) type=button value=頁面設置>
9. <input name=Button onClick=document.all.WebBrowser.ExecWB(10,1) type=button value=屬性>
10. <input name=Button onClick=document.all.WebBrowser.ExecWB(17,1) type=button value=全選>
11. <input name=Button onClick=document.all.WebBrowser.ExecWB(22,1) type=button value=刷新>
12. <input name=Button onClick=document.all.WebBrowser.ExecWB(45,1) type=button value=關閉>

<OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0></OBJECT>
<input name=Button onClick=document.all.WebBrowser.ExecWB(1,1) type=button value=打開>
<input name=Button onClick=document.all.WebBrowser.ExecWB(2,1) type=button value=關閉所有>
<input name=Button onClick=document.all.WebBrowser.ExecWB(4,1) type=button value=另存為>
<input name=Button onClick=document.all.WebBrowser.ExecWB(6,1) type=button value=列印>
<input name=Button onClick=document.all.WebBrowser.ExecWB(6,6) type=button value=直接列印>
<input name=Button onClick=document.all.WebBrowser.ExecWB(7,1) type=button value=列印預覽>
<input name=Button onClick=document.all.WebBrowser.ExecWB(8,1) type=button value=頁面設置>
<input name=Button onClick=document.all.WebBrowser.ExecWB(10,1) type=button value=屬性>
<input name=Button onClick=document.all.WebBrowser.ExecWB(17,1) type=button value=全選>
<input name=Button onClick=document.all.WebBrowser.ExecWB(22,1) type=button value=刷新>
<input name=Button onClick=document.all.WebBrowser.ExecWB(45,1) type=button value=關閉>

三.使用ScriptX.cab控制項

1.下載ScriptX.cab控制項

官網http://www.meadroid.com/scriptx/index.asp

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

這里調用控制項ScriptX.cab
Java代碼 復制代碼

1. <OBJECT id="factory" style="DISPLAY: none" codeBase="${rootUrl}js/smsx.cab#VVersion=6,3,435,20" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" viewastext></OBJECT>

<OBJECT id="factory" style="DISPLAY: none" codeBase="${rootUrl}js/smsx.cab#VVersion=6,3,435,20" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" viewastext></OBJECT>

這段代碼用來載入cab文件,clsid和codebase必須要和你下載的cab中的信息對應,否則組件會載入錯誤,這兩項其實不難找,只要你用winrar打開你下載的cab文件,然後找到擴展名是.inf的文件,然後打開之,就能看到了。

3.調用控制項腳本

Print.js文件
Java代碼 復制代碼

1. function setPrintBase(headerText,footerText,rootUrl) {
2.
3. // -- advanced features ,未曾使用過,有待確認。
4.
5. //factory.printing.SetMarginMeasure(2); // measure margins in inches
6.
7. //factory.SetPageRange(false, 1, 3);// need pages from 1 to 3
8.
9. //factory.printing.printer = "HP DeskJet 870C";
10.
11. //factory.printing.copies = 2;
12.
13. //factory.printing.collate = true;
14.
15. //factory.printing.paperSize = "A4";
16.
17. //factory.printing.paperSource = "Manual feed"
18.
19. var header = (headerText==null||headerText=="")?'默認頁眉':headerText;
20.
21. var footer = (footerText==null||footerText=="")?'默認頁角':footerText;
22.
23. factory.printing.header = "&b"+header+"&b" ;
24.
25. factory.printing.footer = "&b"+footer;
26.
27. factory.printing.portrait = true;
28.
29. factory.printing.leftMargin =10.00;
30.
31. factory.printing.topMargin =10.00;
32.
33. factory.printing.rightMargin =10.00;
34.
35. factory.printing.bottomMargin =10.00;
36.
37. }

function setPrintBase(headerText,footerText,rootUrl) {

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

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;

}

例子
Java代碼 復制代碼

1. <%@ page contentType="text/html;charset=GBK"%>
2.
3. <html>
4. <head>
5. <meta http-equiv="imagetoolbar" content="no">
6. <script language="javascript" src="print.js"></script>
7. <style media="print">
8. .Noprint {DISPLAY: none;}
9. </style>
10. <title>列印測試</title>
11. </head>
12. <OBJECT id="factory" style="DISPLAY: none" codeBase="smsx.cab#VVersion=6,3,435,20" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" viewastext></OBJECT>
13.
14. <script defer>
15. function window.onload() {
16. setPrintBase('頁眉','頁腳');
17. }
18. </script>
19. <body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0">
20. <center class="Noprint">
21. <input type=button value="列印" onclick="factory.printing.Print(true)">
22. <input type=button value="頁面設置" onclick="factory.printing.PageSetup()">
23. <input type=button value="列印預覽" onclick="factory.printing.Preview()">
24. <input type="button" value="關閉" onclick="window.close();">
25. </center>
26. <center>
27. <table width="100%" border="0" cellpadding="0" cellspacing="0">
28. <tr><td align="center"><b>內容</b></td></tr>
29. </table>
30. </center>
31. </body>
32. </html>

<%@ page contentType="text/html;charset=GBK"%>

<html>
<head>
<meta http-equiv="imagetoolbar" content="no">
<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="列印" onclick="factory.printing.Print(true)">
<input type=button value="頁面設置" onclick="factory.printing.PageSetup()">
<input type=button value="列印預覽" onclick="factory.printing.Preview()">
<input type="button" value="關閉" onclick="window.close();">
</center>
<center>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td align="center"><b>內容</b></td></tr>
</table>
</center>
</body>
</html>

四.對比

1.Window.print調用方便,但功能簡單

2.功能更強大,但使用IEWebBrowser有時會報JS沒有許可權的錯誤。

3.ScriptX控制項功能也比較強大,目前在使用這種方式。

這里的也不錯啊,有列印到 word的和excel

http://hi..com/afei0211/blog/item/20523955ca8bebc2b745ae98.html

http://hi..com/hongz1125/blog/item/0152bcfd84ce1e1008244d5c.html

.NET環境下的
http://blog.csdn.net/flygoldfish/archive/2004/08/17/77208.aspx

閱讀全文

與js循環列印小星星相關的資料

熱點內容
maya粒子表達式教程 瀏覽:84
抖音小視頻如何掛app 瀏覽:283
cad怎麼設置替補文件 瀏覽:790
win10啟動文件是空的 瀏覽:397
jk網站有哪些 瀏覽:134
學編程和3d哪個更好 瀏覽:932
win10移動硬碟文件無法打開 瀏覽:385
文件名是亂碼還刪不掉 瀏覽:643
蘋果鍵盤怎麼打開任務管理器 瀏覽:437
手機桌面文件名字大全 瀏覽:334
tplink默認無線密碼是多少 瀏覽:33
ipaddgm文件 瀏覽:99
lua語言編程用哪個平台 瀏覽:272
政采雲如何導出pdf投標文件 瀏覽:529
php獲取postjson數據 瀏覽:551
javatimetask 瀏覽:16
編程的話要什麼證件 瀏覽:94
錢脈通微信多開 瀏覽:878
中學生學編程哪個培訓機構好 瀏覽:852
榮耀路由TV設置文件共享錯誤 瀏覽:525

友情鏈接