// Disable refresh and back button functions window.addEventListener('load', function() { // Prevent F5 and Ctrl+R refresh document.addEventListener('keydown', function(e) { // F5 key if (e.key === 'F5' || // Ctrl + R (e.ctrlKey && e.key.toLowerCase() === 'r') || // Command + R (for Mac) (e.metaKey && e.key.toLowerCase() === 'r')) { e.preventDefault(); return false; } }); // Disable right-click menu document.addEventListener('contextmenu', function(e) { e.preventDefault(); return false; }); // Disable browser back button history.pushState(null, null, location.href); window.addEventListener('popstate', function() { history.pushState(null, null, location.href); }); });