用在PHP里的JS打印函数
程序员文章站
2023-11-25 23:50:40
auto=1立即print,否则timeout毫秒后print,如printpage(0,5000); fu...
auto=1立即print,否则timeout毫秒后print,如printpage(0,5000);
function printpage($auto=1,$timeout=10000) {
if ($auto == 1) {
echo "
< script language="javascript" >
< !-- begin
if (window.print) {
window.print();
}
else {
alert('no printer driver in your pc');
}
// end -- >
< /script >
n";
}
else {
echo "
< script language="javascript" >
< !-- begin
if (window.print) {
settimeout('printcheck()','$timeout');
}
else {
alert('no printer driver in your pc');
}
function printcheck() {
agree = confirm('ok to print now?');
if (agree) window.print();
}
// end -- >
< /script >
n";
}
}