PrintElem无法在最新的Windows更新

时间:2016-09-03 08:07:15

标签: javascript css

我有一个脚本,当点击一个链接时应该打印一个特定的div,它完美无缺,直到最新的Windows更新来了,我一直在使用带有Kiosk模式的Google Chrome,进行静音打印。 我已经尝试过禁用自助服务终端模式,但仍然没有任何反应,当我点击链接时,它只是刷新页面。

链接看起来像这样

<a href="#" onclick="PrintElem('.mydiv5')" />

然后是我的代码

<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('', 'my div', 'height=400,width=600');
            mywindow.document.write('<html><head><title>my div</title>');
            /*optional stylesheet*/ //mywindow.document.write('<link rel="stylesheet" href="main.css" type="text/css" />');
            mywindow.document.write('</head><body><p style="font-family:arial">');
            mywindow.document.write(data);
            mywindow.document.write('</p></body></html>');

            mywindow.document.close(); // necessary for IE >= 10
            mywindow.focus(); // necessary for IE >= 10

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

            return true;
        }

    </script>

最后,最后一点,div我打印

<div class="mydiv5" style="display:none;">
Test
</div>

我可以做些什么来让一切都恢复正常,它发生在我的电脑更新后的同一天。

如果我在网站上标记某些内容并单击“CTRL + P”,则打印得很好。

希望你能提供帮助。

0 个答案:

没有答案