haidong 发表于 2010-2-24 13:34:50

用在PHP里的JS打印函数

<br>                   auto=1立即PRINT,否则timeOut毫秒后PRINT,如printPage(0,5000);<BR><BR><BR>function printPage($auto=1,$timeOut=10000) {<BR>if ($auto == 1) {<BR>echo "<BR>&lt; SCRIPT LANGUAGE="JavaScript" &gt;<BR>&lt; !-- Begin<BR>if (window.print) {<BR>window.print();<BR>}<BR>else {<BR>alert('No printer driver in your PC');<BR>}<BR>// End -- &gt;<BR>&lt; /script &gt;<BR>n";<BR>}<BR>else {<BR>echo "<BR>&lt; SCRIPT LANGUAGE="JavaScript" &gt;<BR><BR>&lt; !-- Begin<BR>if (window.print) {<BR>setTimeout('printCheck()','$timeOut');<BR>}<BR>else {<BR>alert('No printer driver in your PC');<BR>}<BR>function printCheck() {<BR>agree = confirm('OK to print now?');<BR>if (agree) window.print();<BR>}<BR>// End -- &gt;<BR>&lt; /script &gt;<BR>n";<BR>}<BR>}                   <br><br>
页: [1]
查看完整版本: 用在PHP里的JS打印函数