Greg Gum
Greg Gum

Reputation: 37885

How to avoid popup blocker when printing

On an commerce site, the user needs to be able to print an order.

I can do this with a popup window:

w = window.open();
w.document.write(data);
w.print();
w.close();

However, what should I do if the user has a popup blocker in place?

Is there another way of printing I should provide (ie, not using a popup) or should I assume that the user will enable the popup if he really wants to print? Google Maps seems to be using a popup window for printing so this seems to be an acceptable way of addressing this.

So the question is, how do I avoid the popup blocker issue?

Greg

Upvotes: 0

Views: 232

Answers (1)

Kukiwon
Kukiwon

Reputation: 1332

Maybe opening the window in a new tab helps. However, I think it is not possible to control window blocking in JavaScript.

Please see this example:

var OpenInNewTab = function (url )
{
  var win=window.open(url, '_blank');
  win.focus();
}

source: https://stackoverflow.com/a/11384018/1054926

Fiddle: http://jsfiddle.net/Jr8dk/2/. Tested in Safari 7 without Pop-ups disabled.

Upvotes: 1

Related Questions