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

在PHP里的JS打印函数

<br>                   在PHP里的JS打印函数<BR><BR>auto=1立即PRINT,否则timeOut毫秒后PRINT,如printPage(0,5000); <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>   "; <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>   "; <BR> } <BR>}                   <br><br>
页: [1]
查看完整版本: 在PHP里的JS打印函数