Foros del Web » Programando para Internet » Javascript »

Problema IE al recoger string

Estas en el tema de Problema IE al recoger string en el foro de Javascript en Foros del Web. Hola a todos. Tengo un texto inicial y quiero dividirlo en dos. Para ello recorro mediante un "for" el texto inicial y separo el texto ...
  #1 (permalink)  
Antiguo 13/12/2010, 03:52
 
Fecha de Ingreso: junio-2003
Mensajes: 318
Antigüedad: 20 años, 10 meses
Puntos: 0
Pregunta Problema IE al recoger string

Hola a todos.

Tengo un texto inicial y quiero dividirlo en dos. Para ello recorro mediante un "for" el texto inicial y separo el texto en dos variables diferentes antes del caracter numero 200 y despues del caracter numero 200:

function textForSection(textSection) {
var numCharacters = textSection.length;
var newTextVisible = "";
var newTextNoVisible = "";
for (i = 0; i <= (numCharacters - 1); i++) {
if (i <= 220) {newTextVisible = newTextVisible + "" + textSection[i] + "";}
else {newTextNoVisible = newTextNoVisible + "" + textSection[i] + "";}
}
$('#textSection span.textSectionVisible').text(newTextVisible);
$('#textSection div.textSectionNoVisible').text(newTextNoVisible);
}

El problema es que esto me funciona perfectamente en todos los navegadores menos en Internet Explorer donde la variable textSection[i] es "undefined" en cada posicion.

Alguna idea de que estoy haciendo mal????

Gracias a todos.
  #2 (permalink)  
Antiguo 13/12/2010, 04:01
Avatar de zerokilled
Javascripter
 
Fecha de Ingreso: abril-2009
Ubicación: Isla del Encanto, La Borinqueña [+>==]
Mensajes: 8.050
Antigüedad: 15 años
Puntos: 1485
Respuesta: Problema IE al recoger string

no veo nada mal, pero lo que sea pienso que te complicas mucho con un bucle. utiliza las funciones substring para extraer el string por porciones, asi te evitas el bucle.
__________________
la maldad es una virtud humana,
y la espiritualidad es la lucha del hombre contra su maldad.
  #3 (permalink)  
Antiguo 13/12/2010, 05:14
 
Fecha de Ingreso: junio-2003
Mensajes: 318
Antigüedad: 20 años, 10 meses
Puntos: 0
Respuesta: Problema IE al recoger string

Utilizando la funcion substring mucho mas sencillo y funcionando. GRACIAS!!
En cualquier caso sigo sin entender porque no funcionaba mi anterior funcion en IE.

Etiquetas: recoger, string
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 21:20.