window.print(); Repeating Load event

I tried to print something using window.print();

It is working, but whenever I click my print button for the second time without reloading the page (which is unnecessary),
the window print will appear again even though I already click on close button.
After the code runs until $(’#main’).show(); , it goes back to window.print(); again.
And if I tried for the third time, it will reload the window print 3 times and so on.
I’m not sure how to terminate the load event after I close the window for the first time.
I do not want the window to be reloaded again.

This is my code;

self.GetQrCode = function (obj) {
        var ID = obj.Id;
            url: '/QC/GetQrCode',
            cache: false,
            type: 'GET',
            contentType: 'application/json; charset=utf-8',
            data: { rejectsId: ID },
            success: function (rejectsId) {
                //$("#test").attr('src', rejectsId.QRCode);

    self.PrintQrCode = function (obj) {
        $("#test").on("load", function () {

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.