Friday, 23 August 2013

print div class elements

print div class elements

I have a div class:-
<div class="hidden">
This is it.
<asp:Button ID="Button1" runat="server"
Height="23px" style="margin-top: 0px" Width="69px" text="Print"
OnClientClick="PrintElem('#hidden'); return false;"/>
</div>
inside this div class, a list of elements that are dynamically populated.
I am trying to use a print button inside this div class to print all
elements.
function PrintElem(elem) {
Popup($(elem).html());
}
function Popup(data) {
var mywindow = window.open('', '#hidden',
'height=400,width=600');
mywindow.document.write('<html><head><title>Pharmacy
List</title>');
/*optional stylesheet*/ //mywindow.document.write('<link
rel="stylesheet" href="main.css" type="text/css" />');
mywindow.document.write('</head><body >');
mywindow.document.write(data);
mywindow.document.write('</body></html>');
mywindow.print();
mywindow.close();
return true;
}
This works great, except the page that is printed out is blank and titled
'undefined'.

No comments:

Post a Comment