Ver Mensaje Individual
  #1 (permalink)  
Antiguo 29/05/2005, 22:39
Avatar de Pandragon
Pandragon
 
Fecha de Ingreso: abril-2003
Ubicación: Alicante - España
Mensajes: 66
Antigüedad: 21 años, 10 meses
Puntos: 0
Problema con Firefox

Tengo el siguiente script, el problema es que solo funciona con IE, pero no me funciona con firefox:

Código:
function writeImgTag(myField, tag )
{
	var myField = document.getElementById( "NewComment" );

	tag = ' ' + tag + ' ';
	
// IE
	if (document.selection) {
		myField.focus();
		sel = document.selection.createRange();
		sel.text = tag;
		myField.focus();
	}
//MOZILLA/NETSCAPE
	else if (myField.selectionStart || myField.selectionStart == '0') {
		var startPos = myField.selectionStart;
		var endPos = myField.selectionEnd;
		var cursorPos = endPos;
		myField.value = myField.value.substring(0, startPos)
					  + tag
					  + myField.value.substring(endPos, myField.value.length);
		cursorPos += tag.length;
		myField.focus();
		myField.selectionStart = cursorPos;
		myField.selectionEnd = cursorPos;
	}
	else {
		myField.value += tag;
		myField.focus();
	}
}
Revisando el java con firefox me da el siguiente error en el codigo:

Error: myField has no properties

En la línea:

else if (myField.selectionStart || myField.selectionStart == '0') {

Lo cierto es que me estoy volviendo loco y no encuentro donde puede estar el error, si alguien me puede hechar una mano sería de agradecer.