话不多说,先帖代码:

function printDIV(printarea){
var head="<html><head><title></title></head><body>";//先生成头部
var foot="</body></html>";//生成尾部
var newstr=document.all.item(printarea).innerHTML;//获取指定打印区域
var oldstr=document.body.innerHTML;//获得原本页面的代码
document.body.innerHTML=head+newstr+foot;//购建新的网页
window.print();//打印刚才新建的网页
document.body.innerHTML=older;//将网页还原
return false;
}