How can I block a content from being copied and right clicked
...................................I want to block some images and some text........ please I want it fast

Dani AI

Generated

Short primer that builds on and while offering practical, reliable steps.

Client-side tricks (right‑click blockers or selection prevention) only stop casual copying. Anything rendered in the browser can be saved or screenshotted, so server-side controls and policy-level measures are the only realistic deterrents. Useful approaches in combination:

  • Add visible watermarks or low‑resolution previews and keep originals behind authenticated requests or expiring links. Watermarks are a proven deterrent; ImageMagick documents common watermarking workflows (ImageMagick watermarking).
  • Prevent hotlinking and restrict direct file access at the webserver/CDN layer. Blocking other sites from embedding assets reduces casual re-use and bandwidth theft.
  • Treat client-side blocking as UX-only: it deters casual users but is bypassable (events and CSS can be disabled). MDN documents the relevant browser behaviors and shows why client-side blockers are not a security boundary (MDN contextmenu event).
  • Use legal and tracking options: visible copyright notices, metadata, and server logs for attribution or takedown actions.

Quick ImageMagick watermark example (batchable):

convert input.jpg -gravity southeast -pointsize 24 -fill "rgba(255,255,255,0.5)" -annotate +10+10 "© 2025 Company" output.jpg

Combine server-side access control, watermarking, and clear licensing for the best mix of deterrence and practicality. Client-side blocking alone is not sufficient.

Recommended Answers

All 2 Replies

There is no absolute way to protect images or text. If I need to copy a picture that is somehow blocked, I'll take a screen shot or copy it with a screen copy utility.

A couple of things that you can try:
<body oncontextmenu="return false">
to disable right-clicks (but it isn’t 100%)

and/or

<body ondragstart="return false" onselectstart="return false">

There are a bunch of other things that you can try and if you do a search, I'm sure that you will find them. Some are specific to certain browsers and some only work if Javascript is turned on.

You cant
anything that is displayed is downloaded to the client computer before it is displayed,
the user has absolute control

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.