Sunday, August 9, 2009

Cross-browser printing iframe content

I found problem with printing iframe content in Opera. So here is my simple solution:
function print_iframe(s) {
var iframe = window.frames[s];

if(navigator.userAgent.indexOf("Opera") == -1) {
iframe.focus();
iframe.print();
} else {
var opera = window.open(iframe.location);
opera.opener.focus();
opera.print();
opera.close();
opera = null;
}
}

No comments: