简体   繁体   中英

How to check if print dialog is open (Mozilla and Chrome)

I have angularjs application and try to print PDF file from web service, PDF has build in javascript function to show print dialog. When PDF document is loaded in iframe tag <iframe ng-src="{{PDF}}" id="PDFtoPrint"></iframe> the print dialog is shown and it's ok. I try to figure out how to call web service after print dialog is closed. One of ideas is to check if print dialog is open set timeout and check again if it's close then call web service.

I finally found a solution, first of all I want to say that I'm not sure whether it is the best but it seems to work. In my controller i use $window on focus function which means that print dialog is closed (print or cancel nevermind).

$window.onfocus = function () {
                    console.log('This will be called after the user prints');
                    $timeout(Call other function, 1000);
                }
            }

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM