The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Disable Right Click

3 posters

Go down

Solved Disable Right Click

Post by The GreeK January 7th 2013, 5:54 pm

How can I disable Right Click only for images? Smile


Last edited by 1NtRuD3R on January 7th 2013, 6:43 pm; edited 1 time in total
The GreeK
The GreeK
Forumember

Posts : 211
Reputation : 8
Language : Greek, English, French
Location : Greece

http://www.greek-support.net

Back to top Go down

Solved Re: Disable Right Click

Post by Empire_1 January 7th 2013, 5:56 pm

Hi,

Put this in a widget.


Code:


<script language="JavaScript1.2">
/*
Disable right click script II (on images)- By Dynamicdrive.com
For full source, Terms of service, and 100s DTHML scripts
Visit http://www.dynamicdrive.com
*/
var clickmessage="Images and WCF content are copyright of their respective owners. Violators may be prosecuted."
function disableclick(e) {
if (document.all) {
if (event.button==2||event.button==3) {
if (event.srcElement.tagName=="IMG"){
alert(clickmessage);
return false;
}
}
}
else if (document.layers) {
if (e.which == 3) {
alert(clickmessage);
return false;
}
}
else if (document.getElementById){
if (e.which==3&&e.target.tagName=="IMG"){
alert(clickmessage)
return false
}
}
}
function associateimages(){
for(i=0;i<document.images.length;i++)
document.images[i].onmousedown=disableclick;
}
if (document.all)
document.onmousedown=disableclick
else if (document.getElementById)
document.onmouseup=disableclick
else if (document.layers)
associateimages()
</script>
Empire_1
Empire_1
Active Poster

Male Posts : 1391
Reputation : 125
Language : English, Spanish, Mandarin, C++
Location : Summoner's Rift

Back to top Go down

Solved Re: Disable Right Click

Post by The GreeK January 7th 2013, 6:04 pm

If I have done it correctly, it looks like this:

Disable Right Click OWHD4

?
The GreeK
The GreeK
Forumember

Posts : 211
Reputation : 8
Language : Greek, English, French
Location : Greece

http://www.greek-support.net

Back to top Go down

Solved Re: Disable Right Click

Post by Sanket January 7th 2013, 6:14 pm

Yes I believe.
Sanket
Sanket
ForumGuru

Male Posts : 48766
Reputation : 2830
Language : English
Location : Mumbai

Back to top Go down

Solved Re: Disable Right Click

Post by The GreeK January 7th 2013, 6:16 pm

It doesn't work.
The GreeK
The GreeK
Forumember

Posts : 211
Reputation : 8
Language : Greek, English, French
Location : Greece

http://www.greek-support.net

Back to top Go down

Solved Re: Disable Right Click

Post by Sanket January 7th 2013, 6:33 pm

Add this code in Modules> Javascript Code Management
Enable Javascript code management : Yes
Create a new javascript
placement: In all the pages.


Code:
    function nocontext(e) {
        var clickedTag = (e==null) ? event.srcElement.tagName : e.target.tagName;
        if (clickedTag == "IMG") {
            alert(alertMsg);
            return false;
        }
    }
    var alertMsg = "Image context menu is disabled";
    document.oncontextmenu = nocontext;

Reference: http://www.bloggersentral.com/2012/05/disable-right-click-on-images.html
Sanket
Sanket
ForumGuru

Male Posts : 48766
Reputation : 2830
Language : English
Location : Mumbai

Back to top Go down

Solved Re: Disable Right Click

Post by The GreeK January 7th 2013, 6:42 pm

Sanket you are a God!!

Solved
The GreeK
The GreeK
Forumember

Posts : 211
Reputation : 8
Language : Greek, English, French
Location : Greece

http://www.greek-support.net

Back to top Go down

Solved Re: Disable Right Click

Post by Sanket January 7th 2013, 6:44 pm

Topic Solved & Locked
Sanket
Sanket
ForumGuru

Male Posts : 48766
Reputation : 2830
Language : English
Location : Mumbai

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum