js打印指定区域

song  2016-4-27
0


function Printpart(id_str)//id-str 内容中的id
{
      var el = document.getElementById(id_str);
      var iframe = document.createElement('IFRAME');
      var doc = null;
      iframe.setAttribute('style', 
                          'position:absolute;
                           width:0px;
                           height:0px;
                           left:-500px;
                           top:-500px;');
      document.body.appendChild(iframe);
      doc = iframe.contentWindow.document;
      doc.write('标题:专业网站开发http://www.evebit.com'); 
                 tables = el.innerHTML; doc.close(); 
                 iframe.contentWindow.focus(); 
                 iframe.contentWindow.print(); 
                 if (navigator.userAgent.indexOf("MSIE") > 0) { 
                     document.body.removeChild(iframe); 
                 } 
}

游客  现在