在项目写了一个打印功能。用的是iframe、。其中需要打印的信息就通过ajax获取的。就一个层。问题出来了。打印的时候ie6,7没有问题。全部都打印出来了。IE8 只能打印1页。google了2天。修改无数。无解。有没有遇到这种情况的。

解决方案 »

  1.   


    var HKEY_Root,HKEY_Path,HKEY_Key; 
    HKEY_Root="HKEY_CURRENT_USER"; 
    HKEY_Path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\"; 
    //设置网页打印的页眉页脚为空 
    function PageSetup_Null() 

     try 
     { 
      var Wsh=new ActiveXObject("WScript.Shell"); 
      HKEY_Key="header"; 
      Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,""); 
      HKEY_Key="footer"; 
      Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,""); 
     } 
     catch(e){} 

    PageSetup_Null();
    var count=0;
    function hiddentr(id){
    document.getElementById(id).style.display='none';
    }
    function DP(div , divclass) {
    if (window.print) 
    {
    $('.'+divclass).html('');
    var Div1 = $('#'+div).html();

    if(Div1==null) {
    return false;
    }
    var body ='<table width="640" border="0" cellspacing="0" cellpadding="5">' +
    ' <tr> ' +
    ' <td> ' + Div1 + 
    ' </td>' +
    ' </tr>' +
    '</table>';
    document.body.innerHTML = '<center>' + body + '</center>';
    window.print();
    window.history.go(0);
    }
    }传过来的div是ajax获取的返回值