Skip to content

Instantly share code, notes, and snippets.

@NeilHanlon
Forked from ckknight/inhouse.js
Created June 25, 2013 03:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NeilHanlon/5855610 to your computer and use it in GitHub Desktop.
Save NeilHanlon/5855610 to your computer and use it in GitHub Desktop.
(function(){
var oldPrint = window.print;
var slice = Array.prototype.slice;
window.print = function () {
if (typeof window.onbeforeprint === "function") {
window.onbeforeprint.apply(this, slice.call(arguments));
}
oldPrint.apply(this, slice.call(arguments));
if (typeof window.onafterprint === "function") {
window.onafterprint.apply(this, slice.call(arguments));
}
};
}());
window.onafterprint = function(){window.close();};
window.print();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment