Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Thammynha

Como bloquear CTRL e seleção de texto no Firefox ?

Recommended Posts

Bom dia !!!

 

Estou com um probleminha... para variar, os scripts funcionam perfeitamente no IE mas no Firefox não.

 

O script abaixo é para bloquear o CTRL e a seleção de texto;

 

<script language="JavaScript1.2">
function disableselect(e){
return false
}

function reEnable(){
return true
}

//if IE4+
document.onselectstart=new Function ("return false")

//if NS6
if (window.sidebar){
document.onmousedown=disableselect
document.onclick=reEnable
}
</script>



<script language=JavaScript1.2>
function right(e) {
if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2)){
alert("   Cópia não autorizada   ");
return false;
}
else if (navigator.appName == 'Microsoft Internet Explorer' &&
(event.button == 2 || event.button == 3)) {
alert("   Cópia não autorizada   ");
return false;
}
return true;
}
document.onmousedown=right;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
window.onmousedown=right;
</script>

Alguem pode dizer como fazer funcionar no Firefox ?

 

Obrigada!

Compartilhar este post


Link para o post
Compartilhar em outros sites

Abaixo segue minha contribuição, inclua o script depois da tag body ou dentro do evento load.

 

//Seleção de textos
document.onselectstart = function() {return false;};
document.onmousedown= document.onselectstart;

///Botão direito
document.body.oncontextmenu = function(e){ 
	if(window.event)
	{ 
		return (event.returnValue = false)
	} else { 
		e.preventDefault()
	} 
};

window.onmousedown = function(){ 
if(window.event){
	if(event.button == 2 || event.button == 3){
	return (event.returnValue = false) 
	}
}
}

Compartilhar este post


Link para o post
Compartilhar em outros sites

Oii Klaygomes!!!

 

Obrigada... mas não funcionou....

 

=\

 

maaaas... uma amiga minha encontrou o código e me passou!!

 

se alguem precisar, fica aqui a minha contribuição!!

 

colar dentro da tag <head>

 

<script type="text/javascript">
function disableSelection(target){
if (typeof target.onselectstart!="undefined") //IE route
target.onselectstart=function(){return false}
else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
target.style.MozUserSelect="none"
else //All other route (ie: Opera)
target.onmousedown=function(){return false}
target.style.cursor = "default"
}
</script>

 

colar antes da tag </body>

 

<script type="text/javascript">
disableSelection(document.body) //disable text selection on entire body of page
</script>

 

 

Vlwwwww http://forum.imasters.com.br/public/style_emoticons/default/clap.gif

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.