I have a "heavy" html5 webapp, that allows users to print content. When user click my print button, I generate some iframe, populate that with content and then invoke the javascript print() method. Everything works fine.
But, if the user chose to cancel printing on the print-preview/print modal in Chrome, an click event/mousedown event is sent to my app right after the modal is closed.
Any way to prevent this behavior, is it a bug in Chrome?
I am currently using Chrome 38.0.2125.111 in OSX
You can attach a click event to the cancel button and use preventDefault
. Here's an example with jquery.
$('.cancel').click(function(e){
e.preventDefault();
});
If you can only use javascript just use onclick
and do the same thing.
<button onclick="myFunction(this)">Close</button>
function myFunction(ev) {
ev.preventDefault();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.