Ver Mensaje Individual
  #7 (permalink)  
Antiguo 06/08/2019, 05:44
JUMASOL
 
Fecha de Ingreso: noviembre-2005
Mensajes: 889
Antigüedad: 18 años, 5 meses
Puntos: 8
Respuesta: Eventos onclick fallan por falta de id

Esto funciona perfectamente:

Código:
var enlace1 = document.getElementById("v1");
if(enlace1){
document.getElementById("v1").onclick = function(){document.location = "pagina1";};
}
var enlace2 = document.getElementById("v2");
if(enlace2){
document.getElementById("v2").onclick = function(){document.location = "pagina2";};
}	
var enlace3 = document.getElementById("v3");
if(enlace3){
document.getElementById("v3").onclick = function(){document.location = "pagina3";};
}
var enlace4 = document.getElementById("v4");
if(enlace4){
document.getElementById("v4").onclick = function(){document.location = "pagina4";};
}
var enlace5 = document.getElementById("v5");
if(enlace5){
document.getElementById("v5").onclick = function(){document.location = "pagina5";};
}
var enlace6 = document.getElementById("v6");
if(enlace6){
document.getElementById("v6").onclick = function(){document.location = "pagina6";};
}
var enlace7 = document.getElementById("v7");
if(enlace7){
document.getElementById("v7").onclick = function(){document.location = "pagina7";};
}
var enlace8 = document.getElementById("v8");
if(enlace8){
document.getElementById("v8").onclick = function(){document.location = "pagina8";};
}
var enlace9 = document.getElementById("v9");
if(enlace9){
document.getElementById("v9").onclick = function(){document.location = "pagina9";};
}
var enlace10 = document.getElementById("v10");
if(enlace10){
document.getElementById("v10").onclick = function(){document.location = "pagin10";};
}
var enlace11 = document.getElementById("v11");
if(enlace11){
document.getElementById("v11").onclick = function(){document.location = "pagina11";};
}
var enlace12 = document.getElementById("v12");
if(enlace12){
document.getElementById("v12").onclick = function(){document.location = "pagina12";};
}
¿Algún problema?