Skip to content

Instantly share code, notes, and snippets.

@mgd020
Created December 6, 2019 00:29
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 mgd020/5d73d2c901b3e41364893488521ac467 to your computer and use it in GitHub Desktop.
Save mgd020/5d73d2c901b3e41364893488521ac467 to your computer and use it in GitHub Desktop.
Override print dialog
function forceOpen() {
var url = "http://www.google.com";
window.open(url) ? location.reload() : (location.href = url);
}
window.addEventListener("beforeprint", function (e) { e.preventDefault(), forceOpen() })
window.matchMedia("print").addListener(function (e) { e.matches && forceOpen() })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment