[英]media print css on specific div
I use @media print for print html page. 我使用@media print来打印html页面。
@media
print work fine in simple html page. @media
打印可以在简单的html页面中正常工作。
But when I call javascript the @media
css not work on document. 但是,当我调用javascript时,@ @media
CSS无法在文档上运行。
My javascript code is 我的JavaScript代码是
<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.1.min.js" > </script>
<script type="text/javascript">
function PrintElem(elem)
{
Popup($(elem).html());
}
function Popup(data)
{
var mywindow = window.open('', 'mydiv', 'height=400,width=600');
mywindow.document.write(data);
mywindow.print();
mywindow.close();
return true;
}
</script>
How can write media print css for work on specific div. 如何在特定div上写媒体打印CSS以便工作。
You have to write the CSS into that new window. 您必须将CSS写入该新窗口。 The new window is a completely separate environment from the window that opens it, and the CSS in the original window will have absolutely no effect on the popup. 新窗口与打开它的窗口是一个完全独立的环境,原始窗口中的CSS对弹出窗口绝对没有影响。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.