Foros del Web » Programando para Internet » Javascript »

Problema con Firefox

Estas en el tema de Problema con Firefox en el foro de Javascript en Foros del Web. Hola! que tal? Amigos, tengo el siguiente problema... Tengo el siguiente codigo para usarlo como editor de texto: Código HTML: <html> <head> <script type= "text/javascript" ...
  #1 (permalink)  
Antiguo 06/02/2006, 14:45
 
Fecha de Ingreso: febrero-2006
Mensajes: 60
Antigüedad: 18 años, 2 meses
Puntos: 0
Problema con Firefox

Hola! que tal?

Amigos, tengo el siguiente problema...

Tengo el siguiente codigo para usarlo como editor de texto:

Código HTML:
<html>
<head>
<script type="text/javascript">
	var thisForm;
	function getMozSelection(txtarea) {
		var selLength = txtarea.textLength;
		var selStart = txtarea.selectionStart;
		var selEnd = txtarea.selectionEnd;
		if (selEnd==1 || selEnd==2) selEnd=selLength;
		return (txtarea.value).substring(selStart, selEnd);
	}
	
	function mozWrap(txtarea, lft, rgt) {
		var selLength = txtarea.textLength;
		var selStart = txtarea.selectionStart;
		var selEnd = txtarea.selectionEnd;
		if (selEnd==1 || selEnd==2) selEnd=selLength;
		var s1 = (txtarea.value).substring(0,selStart);
		var s2 = (txtarea.value).substring(selStart, selEnd)
		var s3 = (txtarea.value).substring(selEnd, selLength);
		txtarea.value = s1 + lft + s2 + rgt + s3;
	}
	
	function IEWrap(lft, rgt) {
		strSelection = document.selection.createRange().text;
		if (strSelection!="") {
		document.selection.createRange().text = lft + strSelection + rgt;
		}
	}
	
	function wrapSelection(txtarea, lft, rgt) {
		if (document.all) {IEWrap(lft, rgt);}
		else if (document.getElementById) {mozWrap(txtarea, lft, rgt);}
	}
	function mouseover(el) {
		el.className = "raise";
		}
	
	function mouseout(el) {
		el.className = "buttons";
	}
	
	function mousedown(el) {
		el.className = "press";
	}
	
	function mouseup(el) {
		el.className = "raise";
	}
</script>
</head>
<body onload="thisForm=document.frmTest;">
<FORM ACTION="?mod=mensajes&zone=enviar" METHOD="post" id="frmTest" name="frmTest">
  <table width="100%">
  <tr>
      <td>Titulo: <input type="text" name="para" size="30" class="campos"  maxlength="30"> </td>
  </tr>
  <tr>
<td>
	 <a href="#" onmouseover="mouseover(this);" onmouseout="mouseout(this);" onmousedown="mousedown(this);" onmouseup="mouseup(this);" onclick="wrapSelection(thisForm.T,'<i>','</i>');"><i>Italic</i></a>
  </tr>
  <tr>
  		<td>
		Color: 
		</td>
  </tr>
   <tr>
	  <td colspan=2 align=center>
	  <textarea rows="10" class="campos" name="T" style="width: 100%;"></textarea></td>
  </tr>
  <tr>
      <td align="center" colspan="2"><input name="T" type="reset" value="Restablecer" class="boton"> <input type=button value="Postiar" class=boton style="font-weight: bold;" onclick="enviarmensaje();"></td>
  </tr>
  </table>
  </FORM>
  </body>
  </html> 
En IE al seleccionar el texto y apretar Italic me agrega los tags <i> correctamente, pero en Firefox no me funciona.

Consegui este script de: massless.org/mozedit/
  #2 (permalink)  
Antiguo 08/02/2006, 12:45
(Desactivado)
 
Fecha de Ingreso: noviembre-2002
Ubicación: Ciudad Autónoma de Buenos Aires
Mensajes: 2.367
Antigüedad: 21 años, 5 meses
Puntos: 317
Hola ZyZtemA :

En realidad esos navegadores tienen su propio editor WYSIWYG incorporado (lo que va a ser muy útil en algunos años).

Hay varios en la web y en el foro

http://www.pepemolina.com/editor/

Editor html

pero supongo que necesitas editar como código fuente.

El error en el tuyo está en un nombre repetido

Código:
onclick="wrapSelection(thisForm.TA,'<i>','</i>'); return false"

<textarea rows="10" class="campos" name="TA" style="width: 100%;"></textarea>
Ah!. Y trata de describir el problema en el título para que todos sepan de qué hablamos.
  #3 (permalink)  
Antiguo 08/02/2006, 20:41
 
Fecha de Ingreso: febrero-2006
Mensajes: 60
Antigüedad: 18 años, 2 meses
Puntos: 0
Gracias! no me di cuenta...

T_T
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 17:13.