windows.print打印部分区域-完美兼容ie/ff火狐浏览器
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>windows.print打印部分区域-完美兼容ie/ff火狐浏览器</title> </head> <body> 不打印的内容 <div id="print_body"> 打印的内容 </div> <input type="button" onclick="javascript:printbody();" value="打印" /> <script language="javascript"> function printbody() { var head='<html><head><title>打windows.print打印部分区域-完美兼容ie/ff火狐浏览器/title></head><body>'; var foot='</body></html>'; var newstr = document.getElementById('print_body').innerHTML; var older = document.body.innerHTML; document.body.innerHTML = head + newstr +foot; window.print(); document.body.innerHTML=older; } </script> </body> </html> |
windows.print打印部分区域-完美兼容ie/ff火狐浏览器