← Desenvolvimento

Scripts para evitar o "right clicking"

Lida 9194 vezes

Offline

fpware 
Fundador
Mensagens 15318 Gostos 7
Troféus totais: 38
Trófeus: (Ver todos)
Linux User Mobile User Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter Level 5

Aqui estão alguns scripts diferentes para evitar que o visitante possa aceder ao menu de contexto, clicando com o botão direito do rato na página.

O mais simples:

Para colocar na tag BODY:

Código: [Seleccione]
<body oncontextmenu="return false" ondragstart="return false" onselectstart="return false">

oncontextmenu="return false" - impede que o utilizador abra o menu de contexto

ondragstart="return false" - faz com que o utilizador não possa arrastar

onselectstart="return false" - faz com que o utilizador não possa seleccionar nada

Outro que faz aparecer uma mensagem quando o visitante clica com o botão direito do rato na página:

Colocar o seguinte código entre as tags <head></head>:

Código: [Seleccione]
<script language="Javascript1.2">
am = "O texto que quer que apareça na mensagem!";
bV  = parseInt(navigator.appVersion)
bNS = navigator.appName=="Netscape"
bIE = navigator.appName=="Microsoft Internet Explorer"

function nrc(e) {
   if (bNS && e.which > 1){
      alert(am)
      return false
   } else if (bIE && (event.button >1)) {
     alert(am)
     return false;
   }
}

document.onmousedown = nrc;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (bNS && bV<5) window.onmousedown = nrc;

</script>


Por último, este código faz com que se abra uma pop-up sempre que o utilizador clica com o botão direito do rato:

Colocar o seguinte código entre as tags <head></head>:

Código: [Seleccione]
<script language="JavaScript">
PopUpURL    = "http://www.oseusite.com/asuapagina.html";
PopUpLeft   =  100;
PopUpTop    =  100;
PopUpWidth  =  500;
PopUpHeight =  100;

// -------------------------------------
// Não editar a partir daqui.
// -------------------------------------

isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;
popO='left='+PopUpLeft+',top='+PopUpTop+',width='+PopUpWidth+',height='+PopUpHeight

if (isIE||isNN){
document.oncontextmenu=checkV;
}else{
document.captureEvents(Event.MOUSEDOWN || Event.MOUSEUP);
document.onmousedown=checkV;}

function checkV(e){
if (isN4){
if (e.which==2||e.which==3){
dPUW=window.open(PopUpURL,'nrc',popO);
return false;
}}else{
dPUW=window.open(PopUpURL,'nrc',popO);
return false;}}

</script>


 8)
Offline

GTO_KAI 
Membro
Mensagens 532 Gostos 13
Troféus totais: 31
Trófeus: (Ver todos)
Level 6 Windows User Super Combination Combination Topic Starter Poll Voter Poll Starter Level 5 Level 4 Level 3

ótimo tópico!!!!!!!! :wink:
Offline

fpware 
Fundador
Mensagens 15318 Gostos 7
Troféus totais: 38
Trófeus: (Ver todos)
Linux User Mobile User Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter Level 5

Thanks ;)
Offline

-RJ- 
Membro
Mensagens 1188 Gostos 0
Troféus totais: 30
Trófeus: (Ver todos)
Apple User Super Combination Combination Topic Starter 50 Poll Votes 10 Poll Votes Poll Voter Level 5 Level 4 Level 3

Thanks, era mesmo disto que eu andava à procura.
 :wink:
Offline

fpware 
Fundador
Mensagens 15318 Gostos 7
Troféus totais: 38
Trófeus: (Ver todos)
Linux User Mobile User Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter Level 5

Óptimo! :D
Offline

GTO_KAI 
Membro
Mensagens 532 Gostos 13
Troféus totais: 31
Trófeus: (Ver todos)
Level 6 Windows User Super Combination Combination Topic Starter Poll Voter Poll Starter Level 5 Level 4 Level 3

eu botei no meu site véio tb xD vlw
Offline

MiguelTavares 
Membro
Mensagens 3871 Gostos 0
Troféus totais: 33
Trófeus: (Ver todos)
Avatar Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter Level 5 Level 4

:D Grande ajuda! :) ;)
Offline

Freedoom 
Membro
Mensagens 723 Gostos 0
Troféus totais: 28
Trófeus: (Ver todos)
Windows User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2

já agora sabem como fazer para nao aparecer o link quando se carrega sobre algum link.
Offline

MiguelTavares 
Membro
Mensagens 3871 Gostos 0
Troféus totais: 33
Trófeus: (Ver todos)
Avatar Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter Level 5 Level 4

Código: [Seleccione]
<p><a href="http://www.LINK-PRINCIPAL.net" onmouseover="window.status='http://www.link-escondido.com'; return true;" onfocus="window.status='http://www.link-escondido.com';return true;" onmouseout="self.status='';return true">O TEXTO PARA O LINK</a>

;)
Offline

MiguelTavares 
Membro
Mensagens 3871 Gostos 0
Troféus totais: 33
Trófeus: (Ver todos)
Avatar Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter Level 5 Level 4

É verdade... isso só funciona em IE, no FF não dá.
Offline

Freedoom 
Membro
Mensagens 723 Gostos 0
Troféus totais: 28
Trófeus: (Ver todos)
Windows User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2

humm a mim não worka nem IE nem FF  :roll:
Offline

MiguelTavares 
Membro
Mensagens 3871 Gostos 0
Troféus totais: 33
Trófeus: (Ver todos)
Avatar Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter Level 5 Level 4

O que te acontece? :roll:
Offline

fpware 
Fundador
Mensagens 15318 Gostos 7
Troféus totais: 38
Trófeus: (Ver todos)
Linux User Mobile User Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter Level 5

No firefox e na SP2 do IE estes scripts não funcam...
Offline

Freedoom 
Membro
Mensagens 723 Gostos 0
Troféus totais: 28
Trófeus: (Ver todos)
Windows User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2

pois :S não ah por ai outros ?
Offline

louro 
Membro
Mensagens 769 Gostos 2
Troféus totais: 29
Trófeus: (Ver todos)
Apple User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2

Tentei todos os codigos e não resultou um. No firefox pior ainda.
Bastava clicar em cima da pub do google com o botao do lado direito do rato e dava para ver o codigo fonte :lol:

Mais vale nao por nada :lol: