pivar
asked on
Disabling CTRL+P, the print dialog, in IE8/9
Hi,
I would like to use CTRL+P as a hotkey in my webapplication. With jquery keydown function I'm able to catch the event and do what is supposed to be done. But although I'm catching the event and returning with the following code, the Printdialog is still shown by IE. Is there a way to disable the dialog?
Thanks,
Peter
I would like to use CTRL+P as a hotkey in my webapplication. With jquery keydown function I'm able to catch the event and do what is supposed to be done. But although I'm catching the event and returning with the following code, the Printdialog is still shown by IE. Is there a way to disable the dialog?
Thanks,
Peter
$(document).keydown(function (e) {
var keycode = e.which ? e.which : (e.keyCode ? e.keyCode : 0);
if (!HotKeyHandler(keycode, e.ctrlKey, e.altKey, e.shiftKey)) {
// Handled if false
e.preventDefault();
e.stopPropagation();
return false;
}
}
ASKER
I'm not sure I understand. How would this help me not showing the dialog when pressing Ctrl+P? As I understand it, it's used with window.print();. I don't want to print.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
No sorry, I tried the openjs shortcut function, but no changes. I still get a printer dialog. But I noticed that the dialog doesn't show if you show an alert-dialog.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I got this issue becuse we're moving an old windowsclient to the web, and wanted to keep the old hotkeys. I've come to the same conclusion as you, thanks for the confirmation. I ended up using Ctrl+Shift instead of Ctrl.
Glad you figured out a solution. IE doesn't make things easy for developers ... that would be much too nice of Microsoft ;)
http://justtalkaboutweb.com/2008/05/09/javascript-print-bypass-printer-dialog-in-ie-and-firefox/