Bug 10376 - Printing cart does not work under IE9
Summary: Printing cart does not work under IE9
Alias: None
Product: Koha
Classification: Unclassified
Component: Browser compatibility (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Marcel de Rooy
QA Contact:
Depends on:
Reported: 2013-05-29 12:26 UTC by Marcel de Rooy
Modified: 2015-06-04 23:23 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Who signed the patch off:
Text to go in the release notes:
Version(s) released in:

Bug 10376: Printing cart does not work under IE9 (2.12 KB, patch)
2013-05-29 12:34 UTC, Marcel de Rooy
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 10376: Printing cart does not work under IE9 (2.53 KB, patch)
2013-06-07 07:15 UTC, Marc Véron
Details | Diff | Splinter Review
[PASSED QA] Bug 10376: Printing cart does not work under IE9 (2.65 KB, patch)
2013-07-14 11:29 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Marcel de Rooy 2013-05-29 12:26:11 UTC
This problem may be older than IE9; I do not know. Cannot check that for now.
Since many patrons have IE9, it would be nice if they could print the contents of the cart on opac.
Somehow this does not work now. See discussions like http://stackoverflow.com/questions/2555697/window-print-not-working-in-ie?rq=1

The proposed patch adds some code for IE. Works with setting a small timeout, calling window.print instead of print, and changing location on receiving focus back. Note that this last trick is also browser dependent.

I do not favor browser dependent code, but at least we reach the goal of enabling the print function again for IE users..
Comment 1 Marcel de Rooy 2013-05-29 12:34:06 UTC Comment hidden (obsolete)
Comment 2 Marc Véron 2013-06-07 07:15:12 UTC Comment hidden (obsolete)
Comment 3 Jonathan Druart 2013-06-07 09:41:53 UTC
Marcel, why do you use the obscure IEprint variable? A user will not be able to print twice the basket?
Comment 4 Marcel de Rooy 2013-06-07 14:38:53 UTC
(In reply to comment #2)
> Signed-off-by: Marc Veron <veron@veron.ch>

Great signoff, Marc, with all these browser versions. Thanks.
Comment 5 Marcel de Rooy 2013-06-07 14:40:14 UTC
(In reply to comment #3)
> Marcel, why do you use the obscure IEprint variable? A user will not be able
> to print twice the basket?

Hi Jonathan,
He should normally not be able. But since I am working with a small timeout of 500 ms, I just want to be sure that it does not fire again.

Thanks for asking,
Comment 6 Chris Cormack 2013-06-25 08:00:11 UTC
I don't have IE so can't test this
Comment 7 Katrin Fischer 2013-07-14 11:29:00 UTC
Created attachment 19625 [details] [review]
[PASSED QA] Bug 10376: Printing cart does not work under IE9

Test plan:
1) Test with Firefox (or any other browser except IE):
Add biblio to cart
Go to Cart and click Print
Does the Cart window come back to its original state after confirm/cancel Print?
2) Test with Internet Explorer (I used IE9; testing another version is fine)
Do the same as above. Is behavior now more or less the same?

Signed-off-by: Marc Veron <veron@veron.ch>

1) Test without patch:
IE 10: Does not show print dialog
IE 9 (Developer Emulation in IE 10): Does not show print dialog (as expected)
FF 21.0 OK
Chrome 27.0.1453.110 m: OK

2) Test with patch:
IE 10: OK
IE 9 (Developer Emulation in IE 10): OK
IE 8 (Developer Emulation in IE 10): OK
IE 7 (Developer Emulation in IE 10): OK
FF 21.0 OK
Chrome 27.0.1453.110 m: OK

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Trusting Marc here, as I don't have IE available.
Regression tests in Firefox and Chromium went well.
Comment 8 Galen Charlton 2013-09-18 16:35:23 UTC
Pushed to master.  Thanks, Marcel!
Comment 9 Tomás Cohen Arazi 2013-11-11 15:14:08 UTC
This patch has been pushed to 3.12.x, will be in 3.12.7.

Thanks Marcel!
Comment 10 David Cook 2013-12-13 07:46:27 UTC
Fun fact: Microsoft have changed the navigator.appName property to "Netscape" in IE11, so this latest fix won't work for newer versions of IE.


Conditional comments were also removed in IE 10 which makes "simpler" separation of browser dependent code impossible.



I've looked at this a million different ways...and there's always a problem.

window.onfocus (works great for IE but doesn't work for Chrome or Firefox.)

window.setTimeout (this has different syntax in different browsers. While you can get it to work with Chrome + IE or Chrome + FF, you can't seem to get it to work with all 3.)


I was able to trigger location.href only after the "afterprint" event fired but it didn't make a difference. It still redirected before printing in IE. 

I tried using this as a guide: http://msdn.microsoft.com/en-us/library/ie/hh273397(v=vs.85).aspx

But I can't think of any way to really identify IE as separate from FF or Chrome without more browser detection of some kind. 

The thing is that "window.onfocus" does work, but you have to remove focus from a FF or Chrome window by switching windows and coming back to it. 


I don't know if there really is a solution to this problem.

It probably wouldn't help to open a new window, print, and close, because I think the same thing happens. 


I tried "<body onload="window.print()" onfocus='location.href="/cgi-bin/koha/opac-basket.pl?bib_list=[% bib_list %][% IF ( verbose ) %]&verbose=1[% END %]";'>", which works in IE and Firefox, but not Chrome...

I don't know.
Comment 11 David Cook 2013-12-17 04:17:59 UTC
The thing to do is probably to open yet another window for the print.

Would people be opposed to that idea?