Estoy intentando proteger cierto contenido en una web y e gustaría saber como predominan los scripts.
Lo primero que no tengo mucha idea e igual he colado algún fallo gordo.
Os pego el código a continuación. Lo que intento es hacer que "Elemento 2" sea el único elemento al que se le pueda pinchar con el botón derecho.
He probado con otras etiquetas como "clase_1.onselectstart = inhabilitar" y si que responde bien, así que tiene que haber algún tema de predominio en el código de uno sobre otro.
Cita:
A ver si me podéis echar un cable. Gracias. <html>
<head>
<title>Proteccion</title>
</head>
<body>
<p>Elemento 1</p>
<div id="clase_1">
<p>Elemento 2</p>
</div>
<p>Elemento 3</p>
<script>
function inhabilitar()
{
return false;
}
oncontextmenu = inhabilitar
</script>
<script>
function habilitar()
{
return true;
}
clase_1.oncontextmenu = habilitar
</script>
</body>
</html>
<head>
<title>Proteccion</title>
</head>
<body>
<p>Elemento 1</p>
<div id="clase_1">
<p>Elemento 2</p>
</div>
<p>Elemento 3</p>
<script>
function inhabilitar()
{
return false;
}
oncontextmenu = inhabilitar
</script>
<script>
function habilitar()
{
return true;
}
clase_1.oncontextmenu = habilitar
</script>
</body>
</html>