Skip to content

Instantly share code, notes, and snippets.

@mgd020
Created October 29, 2019 02:24
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/f4d3e72ed38c0a76cf21f76b51a430b5 to your computer and use it in GitHub Desktop.
Save mgd020/f4d3e72ed38c0a76cf21f76b51a430b5 to your computer and use it in GitHub Desktop.
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