맛집 여행 캠핑 일상 생활

자바스크립트 프린터 출력 이벤트 알아내기 본문

JAVASCRIPT

자바스크립트 프린터 출력 이벤트 알아내기

영은파더♥ 2017. 4. 19. 16:08

자바스크립트 프린터 출력 이벤트 알아내기


javascript 로 인쇄의 시작과 종료를 catch 하는 방법니다.


if(window.matchMedia) {

var mediaQueryList = window.matchMedia('print');

mediaQueryList.addListener(function(mql){

if (mql.matches) {

beforePrint();

} else {

afterPrint();

}

});

}

window.onbeforeprint = beforePrint;

window.onafterprint = afterPrint;

function beforePrint() {

alert('인쇄를 시작전 입니다.');

}

function afterPrint() {

alert('인쇄가 완료되었습니다.');

}


Trackback : | Comments :