admin管理员组文章数量:1431037
I have a div of a gridview that needs to be printed. I am using a CallPrint JavaScript method to print the div. I need to add a header and also re-size the div to fit the page better. Here is the CallPrint method.
function CallPrint(strid) {
var prtContent = document.getElementById(strid);
var WinPrint =
window.open('', '', 'letf=0,top=0,width=800,height=550,toolbar=0,scrollbars=0,status=0');
WinPrint.document.write(prtContent.innerHTML);
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
prtContent.innerHTML = strOldOne;
} //Generating Pop-up Print Preview page
I have a div of a gridview that needs to be printed. I am using a CallPrint JavaScript method to print the div. I need to add a header and also re-size the div to fit the page better. Here is the CallPrint method.
function CallPrint(strid) {
var prtContent = document.getElementById(strid);
var WinPrint =
window.open('', '', 'letf=0,top=0,width=800,height=550,toolbar=0,scrollbars=0,status=0');
WinPrint.document.write(prtContent.innerHTML);
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
prtContent.innerHTML = strOldOne;
} //Generating Pop-up Print Preview page
Share
Improve this question
asked Sep 2, 2011 at 15:36
Lucas Lucas
1251 gold badge2 silver badges11 bronze badges
3
- You don't ask any questions here. – GAgnew Commented Sep 2, 2011 at 15:40
- 1 Instead of js why don't you write a dedicated CSS file for media="print"? (take a look here: alistapart./articles/goingtoprint) – daveoncode Commented Sep 2, 2011 at 15:42
- This was helpful...it made it much easier to print and style how the page should look! Thanks! – Lucas Commented Sep 2, 2011 at 20:53
1 Answer
Reset to default 4This is not the way to go.
Instead you should have something like <link rel="stylesheet" type="text/css" media="print" href="print.css" />
at the top of your html file, and change that element by providing cutom CSS for the print.
Here for more reading : http://www.alistapart./articles/goingtoprint/
本文标签: javascriptResize a div when printingStack Overflow
版权声明:本文标题:javascript - Resize a div when printing - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745509206a2661389.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论