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>HTner.body.inininML = 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