How to set the Print button of the Preview to print directly?

1

I have the following function that prints to generate preview:

<script src="Scripts/jquery-1.10.2.min.js"></script>
<script>
    $(document).ready(function () {
        $("input#imprime").on('click', function (ev) {
            CallPrint();
            clickimprime();
        });
    });
    function CallPrint() {
        var divToPrint = document.getElementById('main1');
        var newWin = window.open('width=100,height=100', '_blank');
        newWin.focus();
        newWin.document.open();
        newWin.document.write(divToPrint.innerHTML);
        newWin.document.close();
        setTimeout(function () { newWin.close(); }, 10);
    }
    function clickimprime() {
        $("button.print").click();
    }
</script>

But what I want, that when the preview is opened, the print button is clicked automatically, calling the clickimprime function.

I would like to know how I could trigger that button to click. I would appreciate your help, of course, thank you.

    
asked by Danilo 16.11.2017 в 17:30
source

0 answers