Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

override print command javascript

function beforePrint() {
    console.log('Do something special before print');
}

function afterPrint() {
    console.log('Do something after print');
}

if (window.matchMedia) {
    window.matchMedia('print').addListener(function (mql) {
        if (mql.matches) {
            beforePrint();
        }
        else {
            afterPrint();
        }
    });
}
// For IE, does not attach in browsers that do not support these events
window.addEventListener('beforeprint', beforePrint, false);
window.addEventListener('afterprint', afterPrint, false);
Comment

PREVIOUS NEXT
Code Example
Javascript :: sus 
Javascript :: javascript loop all depths recursive object 
Javascript :: npm view parent package 
Javascript :: buffering_seeking_time_ranges 
Javascript :: amazing js hacls prank 
Javascript :: suisie with c 
Javascript :: convert utc time to specific timezone javascript 
Javascript :: es6-map-an-array-of-objects-to-return-an-array-of-objects-with-new-keys 
Javascript :: cors error in post request resolved 
Javascript :: howler.js play file 
Javascript :: Ajax Mixed content blocked 
Javascript :: Get value from ionRangeSlider in jquery 
Javascript :: jquery to vanilla javascript 
Javascript :: js pageFlip 
Javascript :: React custom hook refetch data 
Javascript :: gtag.js xample 
Javascript :: scale sprite matter.js 
Javascript :: sort string array object javascript 
Javascript :: bug in javascript 
Javascript :: Content-script overlay for extension 
Javascript :: javascript check if input is empty 
Javascript :: javascript regex tester online 
Javascript :: appendchild js 
Javascript :: clear contents of dependent drop down list automatically javascript stack overflow 
Javascript :: jquery image onerror not working 
Javascript :: sweet form 
Javascript :: missing state 
Javascript :: nestjs openapi yaml file 
Javascript :: falsy value in javascript 
Javascript :: app script with success handler response null 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =