printing div content with css applied

后端 未结 8 895
北海茫月
北海茫月 2020-12-28 17:13

I am working on a project and I want to print div content.The code which I am using is fulfilling my requirements,but I am getting simple output without Css applied to it an

8条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-28 17:33

           function printpage() {
               var getpanel = document.getElementById("<%= Panel1.ClientID%>");
               var MainWindow = window.open('', '', 'height=500,width=800');
               MainWindow.document.write('');
               MainWindow.document.write("");
               MainWindow.document.write('');
               MainWindow.document.write(getpanel.innerHTML);
               MainWindow.document.write('');
               MainWindow.document.close();
               setTimeout(function () {
                   MainWindow.print();
               }, 500)
               return false;
    

    }

提交回复
热议问题