[Javascript] 列印功能 懶人Code

[Javascript] 列印功能 懶人Code


<script type="text/javascript"> 
   
function printform()
{
       var printContent = document.getElementById('<%= form1.ClientID %>'); 
       var windowUrl = 'about:blank';
       var uniqueName = new Date(); 
       var windowName = 'Print' + uniqueName.getTime(); 
       var printWindow = window.open(windowUrl, windowName); 
    
       printWindow.document.write(printContent.innerHTML); 
       printWindow.document.close(); 
       printWindow.focus();             
       printWindow.print(); 
       printWindow.close(); 
} 
</script>

 

論壇討論:http://social.msdn.microsoft.com/Forums/zh-TW/236/thread/ae03d104-f7ef-41bf-b92b-65073402b6c1