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.

How to disable right click

4 posters

Go down

In progress How to disable right click

Post by Hellrose July 10th 2011, 3:18 am

How to disable right click? so no one can copy the image link of my pictures in my forum?
Hellrose
Hellrose
Forumember

Posts : 202
Reputation : 0
Language : English

Back to top Go down

In progress Re: How to disable right click

Post by KingOfSports July 10th 2011, 3:31 am

They can still copy it by using the source code or by clicking the image and posting it as the URL.

Code:
<body oncontextmenu="return false"</body>

This will give you a popup message:

Code:
 function Plan() {
alert('Your Text Here');
 return(false);
}
document.oncontextmenu = iPlan;
KingOfSports
KingOfSports
Hyperactive

Male Posts : 2487
Reputation : 38
Language :
Location :

Back to top Go down

In progress Re: How to disable right click

Post by Base July 10th 2011, 10:04 am

You could also try adding this code:

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="Right click disabled on images!"

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>

That will disable right click on all images. Credits to Dynamic Drive. Wink
Base
Base
Forumaster

Male Posts : 10386
Reputation : 1695
Language : English and French
Location : United Kingdom, England

http://forumotionhub.net

Back to top Go down

In progress Re: How to disable right click

Post by msedgley July 27th 2011, 12:07 pm

does this get posted in the home message
msedgley
msedgley
Forumember

Female Posts : 618
Reputation : 35
Language : English
Location : UK

http://www.rateoffire.com

Back to top Go down

In progress Re: How to disable right click

Post by Base July 27th 2011, 4:51 pm

Either that, a widget or I think it can now be posted as a Javascript code in the administration panel as well. Wink
Base
Base
Forumaster

Male Posts : 10386
Reputation : 1695
Language : English and French
Location : United Kingdom, England

http://forumotionhub.net

Back to top Go down

Back to top


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