I want to print a page to do so I have to click CTRL + P, so I would like to make a link to ease the process. Any help is appreciated!
Asked
Active
Viewed 3.9k times
11
-
3Answered here: http://stackoverflow.com/questions/242182/how-can-i-pop-up-a-print-dialog-box-using-javascript. Please use google or built in stackoverflow browser efficiently... – SzybkiSasza Jun 08 '15 at 14:16
-
2How about just calling `window.print();`?? – epascarello Jun 08 '15 at 14:16
-
1@SzybkiSasza I have searched on google, I got results using php, so I tought asking here, I also searched here and I didn't get what I was looking for. – Anas Abouzaradi Jun 08 '15 at 15:12
-
Yes. sometimes window.print is not working. But ctrl+p event is working fine. If anybody knows the issue – selvan Oct 17 '18 at 12:44
1 Answers
39
You don't need to simulate a CTRL + P keypress to print the window - you can just call window.print()
when required instead.

Rory McCrossan
- 331,213
- 40
- 305
- 339
-
2In most cases, this works fine, `window.print()` is blocking, while CTRL + P is not. For example, trying entering the following in the dev console and then executing print via the two methods. `window.print()` will delay the timeout until the user closes the print dialog, while CTRL + P won't. `window.setTimeout(()=> console.log('timeout callback'), 5000);` – Jon Senchyna Dec 11 '18 at 21:50
-
Hey!! how did you solve this issues?? Can you please help me out. – Cherryl Rarewings Dec 01 '21 at 14:58