Ver Mensaje Individual
  #1 (permalink)  
Antiguo 14/10/2013, 14:18
macr1408
 
Fecha de Ingreso: septiembre-2010
Mensajes: 24
Antigüedad: 13 años, 7 meses
Puntos: 0
Exclamación BBcode a Javascript deja de funcionar al modificar script

Saludos, tengo un campo de texto con bbcode, queria pasarlo a html, buscando por internet consegui este interesante script

Código Javascript:
Ver original
  1. var html = bbcodeParser.bbcodeToHtml("[b]hola[/b]");
  2.  
  3. function sacarhtml(){
  4. alert (html);
  5. }

Y funciona, todo bien, pero cuando quiero modificarlo y hacerlo asi:

Código Javascript:
Ver original
  1. var codigo = document.getElementById("campo").value
  2. var html = bbcodeParser.bbcodeToHtml(codigo);
  3.  
  4. function sacarhtml(){
  5. alert (html);
  6. }

No funciona, el alert me arroja "undefined", alguien sabe por que sucede esto ?

Por si las dudas, dejo el html

Código HTML:
Ver original
  1. <button onClick="sacarhtml()" style="vertical-align:central; float:right">Html </button>
  2.  
  3. <textarea cols="40" rows="40" id="campo"> </textarea>

y aca el link de donde saque el script: http://coursesweb.net/javascript/convert-bbcode-html-javascript_cs

Desde ya, gracias :D