javascript - How to print a panel with button click? -
i had content on panel , looking print 1 on button click, purpose, write following code , calling on button click.
function printpanel() { var panel = document.getelementbyid("<%=pnlprint.clientid %>"); var printwindow = window.open('', '', 'height=100%,width=100%'); printwindow.document.write('<html><head><title> title</title>'); printwindow.document.write('</head><body >'); printwindow.document.write(panel.innerhtml); printwindow.document.write('</body></html>'); printwindow.document.close(); settimeout(function () { printwindow.print(); }, 500); return false; }
everything working fine, other elements in panel misplacing when comes print.. mean labels, buttons not coming in same position we're on panel.
can please let me know how in same position panel on print file? in advance!
first comment ... should isolate css html .. don't write style tags in html style page add new css file , include it.
if did can include file in printwindow creating printing below .... before end of head
tag write include statement include css file print window
printwindow.document.write('<link href="/css/style.css" rel="stylesheet" />');
Comments
Post a Comment