window.print() does not work after JSF-Redirect in IE6

I wanted to present a button with an onclick-handler which invokes the browser printing dialog.

With simple code like this

            <button onclick="window.print();return false;">Print me</button>

It works in Mozilla Firefox 3.x and MS Internet Explorer 6, when the page is called directly. You can click the button, the dialog appears and everything is fine.

Issue 1: But when the page is the result of a JSF-navigation-rule-based <redirect/> the IE6 behaves in a strange way: You click on the button and nothing happens – no js-code is invoked. It works after a manual reload using the F5-key.

Issue 2: I figured out, that not even the following code works in IE6. After such a redirect.

<script type="text/javascript">
    	//your js-code here

Does anybody can reproduce the issues? And knows solutions for them?

Workaround for Issue 1:
Use self.print() instead of window.print(). This works in my usecase in FF3.x and IE6.

            <button onclick="self.print();return false;">Print me</button>

Leave a Reply

Fill in your details below or click an icon to log in: Logo

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

Google photo

You are commenting using your Google 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 )

Connecting to %s