Sei sulla pagina 1di 4

Inhabilitar clic derecho

<span onmousedown='return false'; oncontextmenu='return false;' ondragstart='return


false';>

Al final de HTML

</span>

Inhabilitar selección con el mouse

<script>
document.onselectstart=new Function ('return false');
</script>

Lo mismo pero en código distinto, va dentro del head

<script language="JavaScript">
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>

Maximizar la ventana

window.moveTo(
0,0);
if (document.all) {
top.window.resizeTo(screen.availWidth,screen.availHeight);
}
else if (document.layers||document.getElementById) {
if (top.window.outerHeight<screen.availHeight||
top.window.outerWidth<screen.availWidth){
top.window.outerHeight = screen.availHeight;
top.window.outerWidth = screen.availWidth;
}
}

<!-- EVITAR CLICK DERECHO-->


<script language="Javascript">
<!-- Begin
document.oncontextmenu = function(){return false}
// End -->
</script>

<!-- SELECCION DE TEXTO-->


<script type="text/javascript">
// IE Evitar seleccion de texto
document.onselectstart=function(){
if (event.srcElement.type != "text" && event.srcElement.type != "textarea" && event.srcElement.type !=
"password")
return false
else return true;
};
// FIREFOX Evitar seleccion de texto
if (window.sidebar){
document.onmousedown=function(e){
var obj=e.target;
if (obj.tagName.toUpperCase() == "INPUT" || obj.tagName.toUpperCase() == "TEXTAREA" ||
obj.tagName.toUpperCase() == "PASSWORD")
return true;
/*else if (obj.tagName=="BUTTON"){
return true;
}*/
else
return false;
}
}
// End -->
</script>

<!-- EVITAR ARRASTRAR Y SOLTAR-->


<script language="Javascript">
<!-- Begin
document.ondragstart = function(){return false}
// End -->
</script>

Si deseas que en tu blog no se pueda copiar ni seleccionar tu contenido mediante la inhabilitación del botón
derecho del ratón puedes hacer lo siguiente:

1) Vas a Diseño
2) Edición HTML
3) Busca <body> (teclea Ctrl + F para buscar más rápido)
4) Sustituye <body> por el siguiente código:

<body oncontextmenu='return false;' onmousedown='return false;' onselectstart='return false;'>

5) Clicamos en vista previa y si toda va bien guardamos la plantilla.

De esta forma conseguimos que no se pueda seleccionar nuestro texto y por consiguiente tampoco se pueda hacer clic con
el ratón botón derecho para copiarlo.

Nota: dependiendo de la plantilla utilizada inhabilita el buscador y no se puede escribir en él. Por eso tenemos otras
alternativas:

Otra forma es que cuando el lector pulse el botón derecho para disponerse a copiar el texto le aparezca un mensaje
advirtiendo que no se puede copiar. Para ello hacemos lo siguiente:

Antes de </head> pegamos el siguiente código:

<script type='text/javascript'>
function inhabilitar(){
alert ('Función inhabilitada.');
return false;
}
document.oncontextmenu=inhabilitar;
</script>

El problema de este último truco es que el clic del botón derecho del ratón queda inhabilitado pero se puede seleccionar el
texto y con el teclado pulsar Ctrl + C y copiarlo sin problemas. Para inhabilitar la selección de texto hacemos lo siguiente:

Antes de </head> pegamos el siguiente código:

<script type='text/javascript'>
function disableselect(e){
return false
}
function reEnable(){
return true
}
document.onselectstart=new Function ("return false");
if (window.sidebar){
document.onmousedown=disableselect
document.onclick=reEnable
}
</script>

Nota: Este último truco también me da problemas en mi web ya que me inhabilita el buscador y no permite escribir sobre él.
Si te da estos problemas es mejor optar por la segunda opción de mostrar un mensaje altertando que no se puede copiar el
texto. Problablemente depende del tipo de plantilla y de algunas modificaciones que hayamos hecho en ella. Por tanto,
probadlo bien antes de quedaros con algunas de estas funciones definitivamente.

Este truco, facilitado por Adriana, permite que no se pueda acceder con el raton ->clic derecho ni tampoco permite
seleccionar el texto:

<script>
function event_false() {
window.event.returnValue = false
}
document.onselectstart = event_false
</script>
Recuerda que siempre antes de guardar la plantilla debes hacer clic en vista previa para verificar que no hay errores.

<img src="URL de la imagen" oncontextmenu="alert('Opción deshabilitada');return false"


oncopy="alert('Opción desabilitada');return false"/>

<img src="URL de la imagen" oncontextmenu="alert('Opción deshabilitada');return false"


oncopy="alert('Opción desabilitada');return false"/>

<script language="JavaScript">

var message="";

function clickIE() {if (document.all) {(message);return false;}}

function clickNS(e) {if

(document.layers||(document.getElementById&&!document.all)) {

if (e.which==1||e.which==2||e.which==3) {(message);return false;}}}

if (document.layers)

{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}

else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

document.oncontextmenu=new Function("return false")

function disableselect(e){

return false

function reEnable(){

return true

document.onselectstart=new Function ("return false")

if (window.sidebar){

document.onmousedown=disableselect

document.onclick=reEnable

</script>

<SCRIPT language=JavaScript>

function shant()

alert('Esta pagina no te permite usar el teclado, lo siento')

document.onkeydown=shant;

</SCRIPT>

Potrebbero piacerti anche