The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Disable Right Click

View previous topic View next topic Go down

Solved Disable Right Click

Post by The GreeK on 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
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 on 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
Active Poster

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

Back to top Go down

Solved Re: Disable Right Click

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

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



?

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 on January 7th 2013, 6:14 pm

Yes I believe.

Sanket
ForumGuru

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

http://webartzforum.com

Back to top Go down

Solved Re: Disable Right Click

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

It doesn't work.

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 on 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
ForumGuru

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

http://webartzforum.com

Back to top Go down

Solved Re: Disable Right Click

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

Sanket you are a God!!

Solved

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 on January 7th 2013, 6:44 pm

Topic Solved & Locked

Sanket
ForumGuru

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

http://webartzforum.com

Back to top Go down

View previous topic View next topic Back to top


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