window.print可以打印网页,但有时候我们只希望打印特定控件或内容,怎么办呢? window.print打印指定div 首先我们可以把要打印的内容放在div中,然后用下面的代码进行打印。 复制代码 代码如下: <BR>function printdiv(printpage) <BR>{ <BR>var headstr = "<html><head><title><body>"; <BR>var footstr = ""; <BR>var newstr = document.all.item(printpage).innerHTML; <BR>var oldstr = document.body.innerHTML; <BR>document.body.innerHTML = headstr+newstr+footstr; <BR>window.print(); <BR>document.body.innerHTML = oldstr; <BR>return false; <BR>} <BR> div print //HTML Page //Other content you wouldn't like to print The Div content which you want to print //Other content you wouldn't like to print //Other content you wouldn't like to print