使用javascript在firefox中以横向模式打印

时间:2015-07-22 19:52:38

标签: javascript jquery html firefox

我有30列页面,我需要打印以横向模式容纳所有列。这个只是一个测试页面,我尝试通过旋转页面以横向模式进行打印,但它不会旋转页面。

<html><head><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script></head><body>
<div id="rotate">
<table>
<tr>
<td>Testing Landscape</td>
<td>Testing Landscape</td>
<td>Testing Landscape</td>
<td>Testing Landscape</td>
<td>Testing Landscape</td>
<td>Testing Landscape</td>
<td>Testing Landscape</td>
<td>Testing Landscape</td>
<td>Testing Landscape</td>
<td>Testing Landscape</td>
<td>Testing Landscape</td>
<td>Testing Landscape</td>
<td>Testing Landscape</td>
<td>Testing Landscape</td>
<td>Testing Landscape</td>
<td>Testing Landscape</td>
<td>Testing Landscape</td>
<td>Testing Landscape</td>
</tr>
</table></div>
<button class='gen_btn' onclick='PrintPage("#rotate")'>Print</button>

</body></html>
<script>function PrintPage(elem)
    {
        Popup(jQuery(elem).html(),elem);

    }

    function Popup(data,divName)
    {
        var mywindow = window.open('', 'Store Report', 'height=600,width=600');
        mywindow.document.write('<style>@media print{#rotate{transform:rotate(90deg);-ms-transform:rotate(90deg);-moz-transform:rotate(90deg);-webkit-transform:rotate(90deg);-o-transform:rotate(90deg);transform:rotate(90deg);margin:10px;display: inline-block;}table{display:block;}}</style>');
        mywindow.document.write(data);
      mywindow.document.close();
        mywindow.focus();

        mywindow.print();
        mywindow.close();

        return true;
    }
</script>
</html>

页面仍然以potrait模式打印。这是小提琴https://jsfiddle.net/2wbo4w8v/

0 个答案:

没有答案