Skip to content

Instantly share code, notes, and snippets.

@voronianski
Last active December 14, 2015 12:49
Show Gist options
  • Save voronianski/5089508 to your computer and use it in GitHub Desktop.
Save voronianski/5089508 to your computer and use it in GitHub Desktop.
getprinted.js - custom print method that supports crossbrowser callbacks on after & before print() is fired
/**
* Custom print method plugin
* @param options {Object} - custom callbacks before print inited and after (onBeforePrint, onAfterPrint);
*
* (c) 2012 http://pixelhunter.me MIT Licensed
*/
(function() {
var originalPrint = this.print;
this.getprinted = function (options) {
if (options && options.onBeforePrint) {
options.onBeforePrint(this);
}
originalPrint();
if (options && options.onAfterPrint) {
options.onAfterPrint(this);
}
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment