window.onbeforeunload vs window.print in Internet Explorer
One of my pages shows a discount code, and if you try to navigate away I use the `window.onbeforeunload` to alert the user to write down the code because otherwise it will be lost forever. That page has also a print button, so the user can print the voucher.

The problem is that, in Internet Explorer when the user click on the link `<a href="javascript:window.print();">` , the event `window.onbeforeunload` is raised. This doesn't happen in Chrome.

Is there a way to solve this?

I've seen that if I try this:

`<a href="javascript:alert('herp');window.print();">`

The 'herp' message appears after the warning showed by `window.onbeforeunload`, so I don't know how to fix this.

window.onbeforeunload vs window.print in Internet Explorer
===

One of my pages shows a discount code, and if you try to navigate away I use the `window.onbeforeunload` to alert the user to write down the code because otherwise it will be lost forever. That page has also a print button, so the user can print the voucher.

The problem is that, in Internet Explorer when the user click on the link `<a href="javascript:window.print();">` , the event `window.onbeforeunload` is raised. This doesn't happen in Chrome.

Is there a way to solve this?

I've seen that if I try this:

`<a href="javascript:alert('herp');window.print();">`

The 'herp' message appears after the warning showed by `window.onbeforeunload`, so I don't know how to fix this.
