I need to provide option to print a part of the webpage. This was implemented using the javascript window.print() answered by: Bill Paetzke.
The pop up window opens up (this contains CSS style) and the print dialog also opens. But the CSS style does not show up in the print.
Tried @media =print but that also does not work.
CSS style mainly consists of background color. One option that I got was to replace the background color with an image of 1px * 1px and repeat it. Is there any other way?
Browser: IE7
Code:
.hideMe{
display:block;
}
.PrintClass {
display:block;
}
.NoPrintClass{
display:block;
}
function PrintElem(elem)
{
Popup($('
}
function Popup(data)
{
var mywindow;
mywindow = window.open('', 'mydiv','height=400,width=600,scrollbars=yes','');
mywindow.document.write('
my div');mywindow.document.write('');
mywindow.document.write('
');mywindow.document.write('drop down selected value in parent: '+mywindow.opener.document.getElementById('testSelect').options[mywindow.opener.document.getElementById('testSelect').selectedIndex].text+'
');
mywindow.document.write('contentStarts
');
mywindow.document.write(' using jquery: '+data);
mywindow.document.write(' using javascript: '+mywindow.opener.document.getElementById('mydiv').innerHTML);
mywindow.document.write('
contentEnds');
mywindow.document.write('
');
mywindow.document.write('');
mywindow.document.focus();
mywindow.document.close();
mywindow.print();
return true;
}
This is not be printed
1
2
3
This will also be printed
print bgcolor
print image
some text
dfads