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"> jQuery(document).ready(function(){ //your js-code here }); </script>
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>