Shrujan Shetty
Shrujan Shetty

Reputation: 2394

Site malfunctions due to print functionality in windows chrome

I am building a site which has a gallery and on click of each image we have a larger image displayed.

We also have the option to share on facebook and print.

The print functionality is done by invoking the browser print function:

$("#print").on(isMobile.any() ? 'touchend' : 'click', function (e) {

    var printWindow = window.open('', 'Print Window', 'height=400,width=700');
    printWindow.document.write('<html><head><title>Print Window</title>');
    printWindow.document.write('</head><body ><img src=\'');
    printWindow.document.write($(".large-img").attr("src"));
    printWindow.document.write('\' /></body></html>');
    printWindow.document.close();
    printWindow.print();

});

After closing the print window the images stop loading (click of next button).

Is there any known issue with windows chrome print functionality?

Link: Link Removed

Note: The site works fine on windows Firefox , IE , Chrome in Ubuntu.

Upvotes: 1

Views: 146

Answers (1)

Mario Bellart
Mario Bellart

Reputation: 504

Unfortunately, it seems a Chrome bug:

https://code.google.com/p/chromium/issues/detail?id=363392 https://code.google.com/p/chromium/issues/detail?id=359627

I suggest you to use css print stylesheet instead of opening a popup, for example:

@media print{
    body{
        background:#ffffff;
    }
    .header, .gallety-content, .close-btn, .control-nav, .footer, .bottom-line{
        display:none;
    }
    .middle-content{
        background:none;
    }

    .gallery-overlay{
        left:0;
        top:0;
        position:relative;
    }

    .glry-large-img{
        left:0;
        top:0;
        position:relative;
        margin:0 auto;
        width:100%;
    }

}

Hope it helps

Upvotes: 1

Related Questions