У меня есть следующая кнопка, которая открывает новое окно
<a href="javascript:void(0);" class="btn btn-lg green" onclick="PrintElem('#sample_editable_1', 'Fault Recording')"><i class="fa fa-file-text-o" aria-hidden="true" style="padding-right: 5px;"></i>Run Report</a>
В моем файле js у меня есть эта функция, которая создает окно: -
function PrintElem(elem, h1)
{
Popup($(elem).html(), h1);
}
function Popup(data, h1)
{
var mywindow = window.open('', 'my div', 'height=768,width=1024');
mywindow.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
mywindow.document.write('<html xmlns="http://www.w3.org/1999/xhtml">');
mywindow.document.write('<html><head><title></title>');
mywindow.document.write('<link rel="stylesheet" href="'+base_url+'/css/print1.css'+'" type="text/css" />');
mywindow.document.write('<link rel="stylesheet" href="'+base_url+'/assets/global/plugins/font-awesome/css/font-awesome.min.css'+'" type="text/css" />');
mywindow.document.write('<script src="'+base_url+'js/custom.js'+'" type="text/javascript"></script>');
mywindow.document.write('</head><body>');
mywindow.document.write('<h1 class="pdfTitleDv" >'+h1+'</h1>');
mywindow.document.write($('#window_print').html());
mywindow.document.write('<table border="0" cellpadding="0" cellspacing="0" class="table table-bordered table-striped table-condensed flip-content table-hover datatableDv " id="sample_editable_1">');
mywindow.document.write(data);
mywindow.document.write('</table>');
mywindow.document.write('</body></html>');
mywindow.document.close();
mywindow.focus();
return true;
}
function print(){
window.print();
}
У меня есть следующеекнопка в новом окне, которое я создал там, у меня есть кнопка, я хочу напечатать таблицу, которая находится в окне. пожалуйста, посмотрите HTML ниже: -
<div class="btn-group pull-right btm-btn">
<a href="javascript:void(0);" class="btn btn-lg green" onclick="print()"><i class="fa fa-print" aria-hidden="true" style="padding-right: 5px;"></i>Print</a>
</div>
Я хочу напечатать таблицу, которая находится в новом окне. Может ли кто-нибудь помочь мне добиться этого ?? Любая помощь будет оценена.