diff --git a/src/core/environment.js b/src/core/environment.js index 16971c0b79..34442423b3 100644 --- a/src/core/environment.js +++ b/src/core/environment.js @@ -16,6 +16,7 @@ p5.prototype._lastFrameTime = window.performance.now(); p5.prototype._targetFrameRate = 60; const _windowPrint = window.print; +let windowPrintDisabled = false; /** * The print() function writes to the console area of @@ -43,7 +44,16 @@ const _windowPrint = window.print; */ p5.prototype.print = function(...args) { if (!args.length) { - _windowPrint(); + if (!windowPrintDisabled) { + _windowPrint(); + if ( + window.confirm( + 'You just tried to print the webpage. Do you want to prevent this from running again?' + ) + ) { + windowPrintDisabled = true; + } + } } else { console.log(...args); }