Javascript window.print() does not work in Opera/Chrome browser

You need a timout before calling print in Opera and Chrome (Netscape). Here’s the solution:

function init() {
var objBrowse = window.navigator;
if (objBrowse.appName == “Opera” || objBrowse.appName == “Netscape”) {
setTimeout(‘window.print()’, 1000);
} else {
window.print();
}
}
window.onload = init;

Source http://www.webdeveloper.com/forum/archive/index.php/t-105277.html

About these ads

4 thoughts on “Javascript window.print() does not work in Opera/Chrome browser

  1. cmujica

    No me funcionó, esto si
    onclick=”JavaScript:window.print();return false;”

    Gracias de todas maneras

    Reply
  2. Robert Lane

    Updated for IE 11

    function init() {
    var objAgent = navigator.userAgent;
    if (objAgent.indexOf(“OPR”) > -1 || objAgent.indexOf(“Chrome”) > -1) {
    setTimeout(‘window.print()’, 1000);

    } else {
    window.print();
    }
    }
    window.onload = init;

    Reply

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s