/    Sign up×
Community /Pin to ProfileBookmark

Right-Click Disabled UNINTRUSIVELY!

I’ve seen scripts that disable right-click menus of [URL=http://www.dynamicdrive.com/dynamicindex9/noright2.htm]images only[/URL] (so as not to annoy people who right-click on benign items), and I’ve seen scripts that disable right-click menus [URL=http://www.dynamicdrive.com/dynamicindex9/noright3.htm]silently[/URL] (so as not to annoy people with rude “Gotcha!” alert messages), but I’ve never seen scripts with both features. Is such a script possible?

Thank you! A lot!

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@KeshavaRMay 07.2003 — The simplest way to get into "Silent Mode" and for "Images" too without any coding, for Right Clicks :

<body oncontextmenu="return false">

No matter where the user right clicks on the page.

have a great day

Keshav
Copy linkTweet thisAlerts:
@VladdyMay 07.2003 — First, any scripts like that are a waste of time - there is not much you can do about Print Screen button and other Image Capturing programs. There are also other ways to go around "no right-click" scripts, like disabling javascript.

If you want an unintrusive way to prevent complete morons from copying your images, make a transparent gif and do this:

<div style="background: url(yourrealimage.gif); width=100px; height=100px;"><img src="transparent.gif" width="100" height="100"></div>
Copy linkTweet thisAlerts:
@pdxmitchauthorMay 07.2003 — You can, in effect, disable the Print Screen function by replacing <body> with <body onload=setInterval("window.clipboardData.setData('text','')",20)> . I don't want to disable right-clicking for all of the page, just for the images, and I don't want a notice popping up, I just want nothing to happen. Is that possible?
Copy linkTweet thisAlerts:
@pdxmitchauthorMay 07.2003 — Oh! I didn't understand KeshavaR's post fully -- you can target just one image or individual images by adding...

oncontextmenu="return false"

...to just the image tag! So <img src="copyrighted.jpg" oncontextmenu="return false"> disables right-clicking on that image only. That's brilliant! So much simpler than the javascript way. And no annoying pop-up messages!
Copy linkTweet thisAlerts:
@AdamGundryMay 07.2003 — Only thing is, oncontextmenu is not valid HTML (it is IE-specific) and will fail if Javascript is disabled in the user's browser. Vladdy's method is more reliable, as it does not depend on JS.

Finally, though, the only way to truly protect your images is not to put them online in the first place.

Adam
×

Success!

Help @pdxmitch spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...