Foros del Web » Programando para Internet » Javascript » Frameworks JS »

efecto raro

Estas en el tema de efecto raro en el foro de Frameworks JS en Foros del Web. hola: en esta pagina: http://www.oniricosistemas.com.ar/pr...ules=portfolio tengo armado un js para que al pulsar sobre algun nº me cargue una imagen, todo anda bien salvo que ...
  #1 (permalink)  
Antiguo 10/11/2009, 12:47
Avatar de destor77  
Fecha de Ingreso: noviembre-2004
Ubicación: Gálvez, Santa Fe, Argentina
Mensajes: 2.654
Antigüedad: 19 años, 5 meses
Puntos: 43
efecto raro

hola:
en esta pagina: http://www.oniricosistemas.com.ar/pr...ules=portfolio

tengo armado un js para que al pulsar sobre algun nº me cargue una imagen, todo anda bien salvo que cada vez que se hace click en un nº y carga la imagen correspondiente la pagina se sube sola, y no logro entender porque sucede.

Alguien me podría decir que estoy haciendo mal?

el js es:
Código javascript:
Ver original
  1. $(".thumb a").click(function(){
  2.         var imgHref = $(this).attr('title');  //get the src of the thumbnail
  3.         $(".thumb a").removeClass("selected");  //remove .selected class from all other links
  4.         $(this).addClass("selected");  //add .selected class to current link
  5.         $(".big").stop();
  6.         $(".big").stop().fadeTo(700, 0, function() {  //fade image out
  7.             $('.big').attr('src', imgHref );  //give new image a src attribute
  8.             $('.bighref').attr('href', 'big/' + imgHref );
  9.  
  10.         }).fadeTo("slow", 1);  //fade the image in
  11.     },$(".thumb a").mouseout = function(){    //for onmouseout not used here
  12.     });
  13.    
  14.     $(".thumb2 a").click(function(){
  15.         var imgHref = $(this).attr('title');  //get the src of the thumbnail
  16.         $(".thumb2 a").removeClass("selected");  //remove .selected class from all other links
  17.         $(this).addClass("selected");  //add .selected class to current link
  18.         $(".big2").stop();
  19.         $(".big2").stop().fadeTo(700, 0, function() {  //fade image out
  20.             $('.big2').attr('src', imgHref );  //give new image a src attribute
  21.             $('.bighref2').attr('href', 'big/' + imgHref );
  22.  
  23.         }).fadeTo("slow", 1);  //fade the image in
  24.     },$(".thumb2 a").mouseout = function(){    //for onmouseout not used here
  25.     });

o si conocen alguna mejor forma de hacerlo...

saludos y desde ya muchas gracias
  #2 (permalink)  
Antiguo 10/11/2009, 12:57
Avatar de David
Moderador
 
Fecha de Ingreso: abril-2005
Ubicación: In this planet
Mensajes: 15.720
Antigüedad: 19 años
Puntos: 839
Respuesta: efecto raro

Porque los enlaces apuntan al principio de la página (href="#").

Puedes usar otro elemento (no un enlace) o en todo caso cancelar la acción del evento usando event.preventDefault() (event.returnValue = false para Internet Explorer)
__________________
Por favor, antes de preguntar, revisa la Guía para realizar preguntas.
  #3 (permalink)  
Antiguo 10/11/2009, 13:02
Avatar de mayid
Colaborador
 
Fecha de Ingreso: marzo-2009
Ubicación: BsAs
Mensajes: 4.014
Antigüedad: 15 años, 1 mes
Puntos: 101
Respuesta: efecto raro

Yo hago eso mismo pero escribiendo siempre return false al final de las funciones click:
Cita:
$(".thumb2 a").click(function(){
var imgHref = $(this).attr('title'); //get the src of the thumbnail
$(".thumb2 a").removeClass("selected"); //remove .selected class from all other links
$(this).addClass("selected"); //add .selected class to current link
$(".big2").stop();
$(".big2").stop().fadeTo(700, 0, function() { //fade image out
$('.big2').attr('src', imgHref ); //give new image a src attribute
$('.bighref2').attr('href', 'big/' + imgHref );

}).fadeTo("slow", 1); //fade the image in
},$(".thumb2 a").mouseout = function(){ //for onmouseout not used here
return false;

});
  #4 (permalink)  
Antiguo 10/11/2009, 14:06
Avatar de destor77  
Fecha de Ingreso: noviembre-2004
Ubicación: Gálvez, Santa Fe, Argentina
Mensajes: 2.654
Antigüedad: 19 años, 5 meses
Puntos: 43
Respuesta: efecto raro

hola he probado así como dices tu mayid (pongo todo mi js a lo mejor es por eso)
Código javascript:
Ver original
  1. $(function() {
  2.     $('#legal').click(function(){
  3.         $('#dialog').dialog('open');
  4.         return false;
  5.  
  6.     });
  7.     $("#dialog").dialog({
  8.         autoOpen: false,
  9.         width: 500,
  10.         bgiframe: true,
  11.         height: 340,
  12.         modal: true
  13.     });
  14.  
  15.  
  16.     $('#mensaje').click(function(){
  17.         $("#mensaje").slideUp();
  18.     });
  19.  
  20.     //slider
  21.     $('#rotador').cycle({
  22.         fx:     'fade',
  23.         speed:    5000,
  24.         timeout:  3000,
  25.         height:   207
  26.     });
  27.  
  28.     //acordeon
  29.     $("#accordion").accordion({ active: -1 });
  30.     $("#accordion1").accordion({ active: -1 });
  31.     $("#accordion2").accordion({ active: -1 });
  32.     $("#accordion3").accordion({ active: -1 });
  33.     $("#accordion4").accordion({ active: -1 });
  34.     $("#accordion5").accordion({ active: -1 });
  35.     $("#accordion6").accordion({ active: -1 });
  36.  
  37.     //portfolio
  38.     /*
  39.     $(".thumb a").click(function(){
  40.     var imgHref = $(this).attr('title');  //get the src of the thumbnail
  41.     $(".thumb a").removeClass("selected");  //remove .selected class from all other links
  42.     $(this).addClass("selected");  //add .selected class to current link
  43.     $(".big").stop();
  44.     $(".big").stop().fadeTo(700, 0, function() {  //fade image out
  45.     $('.big').attr('src', imgHref );  //give new image a src attribute
  46.  
  47.     }).fadeTo("slow", 1);  //fade the image in
  48.     },$(".thumb a").mouseout = function(){    //for onmouseout not used here
  49.     });*/
  50.     $(".thumb a").click(function(){
  51.         var imgHref = $(this).attr('title');  //get the src of the thumbnail
  52.         $(".thumb a").removeClass("selected");  //remove .selected class from all other links
  53.         $(this).addClass("selected");  //add .selected class to current link
  54.         $(".big").stop();
  55.         $(".big").stop().fadeTo(700, 0, function() {  //fade image out
  56.             $('.big').attr('src', imgHref );  //give new image a src attribute
  57.             $('.bighref').attr('href', 'big/' + imgHref );
  58.  
  59.         }).fadeTo("slow", 1);  //fade the image in
  60.     },$(".thumb a").mouseout = function(){    //for onmouseout not used here
  61.  
  62.     });
  63.    
  64.     $(".thumb2 a").click(function(){
  65.         var imgHref = $(this).attr('title');  //get the src of the thumbnail
  66.         $(".thumb2 a").removeClass("selected");  //remove .selected class from all other links
  67.         $(this).addClass("selected");  //add .selected class to current link
  68.         $(".big2").stop();
  69.         $(".big2").stop().fadeTo(700, 0, function() {  //fade image out
  70.             $('.big2').attr('src', imgHref );  //give new image a src attribute
  71.             $('.bighref2').attr('href', 'big/' + imgHref );
  72.  
  73.         }).fadeTo("slow", 1);  //fade the image in
  74.     },$(".thumb2 a").mouseout = function(){    //for onmouseout not used here
  75.    
  76.     return false;
  77.     });
  78.  
  79.    
  80.     /*$("#slider").easySlider({
  81.         auto: false,
  82.         continuous: false,
  83.         numeric: true
  84.     });*/
  85.  
  86.  
  87.  
  88.  
  89.     $("a[rel^='prettyPhoto']").prettyPhoto();
  90. });

y no funciona :S
  #5 (permalink)  
Antiguo 10/11/2009, 14:57
Avatar de mayid
Colaborador
 
Fecha de Ingreso: marzo-2009
Ubicación: BsAs
Mensajes: 4.014
Antigüedad: 15 años, 1 mes
Puntos: 101
Respuesta: efecto raro

Si te fijas bien, ya estamos en el campo de mouseover / mouse out:

Cita:
}).fadeTo("slow", 1); //fade the image in
},$(".thumb2 a").mouseout = function(){ //for onmouseout not used here

return false;
Yo no me di cuenta cuando hice copy paste de tu codigo. Fijate bien donde empieza la llave del evento click, y justo antes de que cierre escribi return false;
  #6 (permalink)  
Antiguo 10/11/2009, 20:58
Avatar de destor77  
Fecha de Ingreso: noviembre-2004
Ubicación: Gálvez, Santa Fe, Argentina
Mensajes: 2.654
Antigüedad: 19 años, 5 meses
Puntos: 43
Respuesta: efecto raro

muchas gracias ha funcionado a la perfeccion todo los días se aprende algo nuevo jajaj
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 18:28.