Ver Mensaje Individual
  #6 (permalink)  
Antiguo 11/11/2008, 10:40
SoutlinK
 
Fecha de Ingreso: junio-2007
Mensajes: 189
Antigüedad: 16 años, 10 meses
Puntos: 3
Respuesta: [jQuery] Por que no funciona este código

Vale e encontrado el error, y es la cosa mas extraña que me a sucedido nunca.

Resulta que tengo este coódigo

Código javascript:
Ver original
  1. function resize_images()
  2. {
  3.     var MAX_WIDTH = 640;
  4.    
  5.     $(".postbody img").each
  6.     (
  7.         function()
  8.         {
  9.             alert($(this).attr("src"));
  10.             alert($(this).width());
  11.         }
  12.     );
  13. }

Esto me retorna los siguientes valores:

src: http://img113.imageshack.us/img113/604/omfgom0.jpg
width: 700

Excepto en google chorme que me retorna 0 en width.

Pero que pasa si hago esta modificación:

Código javascript:
Ver original
  1. function resize_images()
  2. {
  3.     var MAX_WIDTH = 640;
  4.    
  5.     $(".postbody img").each
  6.     (
  7.         function()
  8.         {
  9.             var IMAGE_SRC = $(this).attr("src");
  10.             var IMAGE_WIDTH = $(this).width();
  11.             alert(IMAGE_SRC);
  12.             alert(IMAGE_WIDTH);
  13.         }
  14.     );
  15. }

Resultado:

En firefox:
src: http://img113.imageshack.us/img113/604/omfgom0.jpg
width: 700

En Internet Explorer:
src: http://img113.imageshack.us/img113/604/omfgom0.jpg
width: 70

En Google Chorme
src: http://img113.imageshack.us/img113/604/omfgom0.jpg
width: 0

Y no se por que!!!!

Alguna ayuda??? Por favor??