Ziaullah
Ziaullah

Reputation: 65

media print css on specific div

I use @media print for print html page.

@media print work fine in simple html page.

But when I call javascript the @media css not work on document.

My javascript code is

<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.

Upvotes: 2

Views: 887

Answers (1)

Pointy
Pointy

Reputation: 413717

You have to write the CSS into that new window. 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.

Upvotes: 6

Related Questions