Tuesday, June 9, 2020

How to create read only blogger pages



To disable the copying of content from your Blogger post, you can use a few techniques involving CSS or JavaScript to prevent users from selecting text, right-clicking, or using keyboard shortcuts like "Ctrl+C." Here are some common methods:

1. Disable Text Selection Using CSS

You can prevent users from selecting text by adding custom CSS to your Blogger theme. The webkit is older technolgy which is used for this.

Steps:
Go to your Blogger Dashboard.
Click on Theme > Customize.
Click on Advanced > Add CSS.
Paste the following CSS code:
body {
    -webkit-user-select:none;
    -html-user-select:none;
    -moz-user-select:none;
    -ms-user-select:none;
    user-select:none;
}
Click Apply to Blog.

2. By using JavaScript

You can use JavaScript to create read only blogger pages. But remember that it is possible only if the JavaScript is enabled in browser. If JavaScript in browser is disabled by user then it will not work.

Disable Right-Click Using JavaScript
This will disable the right-click functionality, preventing users from using the context menu to copy content.

Steps:
Go to your Blogger Dashboard.
Click on Theme > Edit HTML.
Add the following JavaScript code inside the <head> section:

<script type="text/javascript">
  document.addEventListener('contextmenu', function(e) {
    e.preventDefault();
  });
</script>
Save your changes.

3. Disable Copy Keyboard Shortcuts

To disable the "Ctrl+C" and "Ctrl+X" keyboard shortcuts:

Steps:
Go to your Blogger Dashboard.
Click on Theme > Edit HTML.
Add this script just before the closing </body> tag:
<script type="text/javascript">
  document.onkeydown = function(e) {
    if (e.ctrlKey && (e.key === 'c' || e.key === 'x')) {
      e.preventDefault();
    }
  };
</script>

Save your changes.

Combining Methods
You can combine both of the methods for stronger content protection.

However, remember that these methods make it harder for users to copy your content, but they cannot prevent determined users from finding ways around these measures, like using browser developer tools to copy content.

No comments:

Post a Comment

Hot Topics