How to Protect Your Website Content from Copying and Printing for blogger
Steps to Implement:
- Log in to your Blogger account.
- Go to the Theme section.
- Click on Edit HTML.
- Add the following JavaScript code before the
</body>
tag.
<script>
// Disable right-click
document.addEventListener('contextmenu', function(e) {
e.preventDefault();
alert('Right-click is disabled on this website.');
});
// Disable text selection
document.addEventListener('selectstart', function(e) {
e.preventDefault();
});
// Disable Ctrl + U, Ctrl + S, Ctrl + P, and F12 (View Source/Inspect Element)
document.addEventListener('keydown', function(e) {
if (e.ctrlKey && (e.key === 'u' || e.key === 's' || e.key === 'p') || e.key === 'F12') {
e.preventDefault();
alert('This action is disabled on this website.');
}
});
// Disable Print (Ctrl + P and Print Screen)
document.addEventListener('keydown', function(e) {
if (e.ctrlKey && e.key === 'p') {
e.preventDefault();
alert('Printing is disabled on this website.');
}
});
// Disable Print Screen (PrtSc)
document.addEventListener('keyup', function(e) {
if (e.key === 'PrintScreen') {
alert('Screenshotting is disabled on this website.');
navigator.clipboard.writeText('Screenshots are disabled on this site.');
}
});
// Clear Clipboard on Copy Attempt
document.addEventListener('copy', function(e) {
e.preventDefault();
alert('Copying content is disabled on this website.');
navigator.clipboard.writeText('');
});
</script>
How To Disable Copy Paste in Blogger To Protect Content
Explanation of Features:
- Disable Right-Click: Prevents the context menu from opening.
- Disable Text Selection: Stops users from selecting and copying text.
- Disable Dev Tools: Prevents users from accessing developer tools with common shortcuts like
Ctrl+U
orF12
. - Disable Printing: Blocks the
Ctrl+P
shortcut and alerts users. - Disable Screenshots: Alerts users when the
Print Screen
key is pressed.
Tags:
All IN ONE