我想隐藏打印预览页面 . 实际上我想要点击打印按钮时,应该开始页面打印而不显示打印预览 .

我正在使用以下代码 .

HTML: -

<form id="form1">
    <div id="dvContainer">
        This content needs to be printed.
    </div>
    <input type="button" value="Print Div Contents" id="btnPrint" />
</form>

JQuery: -

<script>
    $("#btnPrint").live("click", function () {
            var divContents = $("#dvContainer").html();
            var printWindow = window.open('', '', 'height=400,width=800');
            printWindow.document.write('<html><head><title>DIV Contents</title>');
            printWindow.document.write('</head><body >');
            printWindow.document.write(divContents);
            printWindow.document.write('</body></html>');
            printWindow.document.close();
            printWindow.print();
        });
</script>

如果可以隐藏打印预览页面,那么请帮帮我 .

我也创造了一个小提琴Click here