Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

138
Vistas
Textarea not working within ForeignObject in a SVG

I'm trying to add a textarea to an SVG. The SVG contains a group container g and I'm appending a foreignObject containing a div which contains a textarea to this group container. The textarea is visible and clicking on the textarea does fire a click event. However, the textarea is not editable. It does not show the cursor to type text at all. I have tried adding contentEditable to both the div and the textarea as well, but that did not work. Here is the code I'm using:

                var myforeign = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject')
                var textdiv = document.createElement("div");
                var input = document.createElement("textarea");
                input.setAttribute("cols", 5000);
                input.setAttribute("rows", 500);
                input.setAttribute("id", "inputtext");
                textdiv.setAttribute("contentEditable", "true");
                textdiv.setAttribute("width", "auto");
                myforeign.setAttribute("width", "100%");
                myforeign.setAttribute("height", "100%");
                textdiv.appendChild(input); 
                myforeign.classList.add("foreign"); //to make div fit text
                textdiv.classList.add("insideforeign"); //to make div fit text
                myforeign.setAttributeNS(null, "transform", "translate(18000 18000)");
                myforeign.appendChild(textdiv);
                group = document.getElementById(this.id);
                group.appendChild(myforeign);
                input.addEventListener("input", this.clickedInput);

Need help to figure out why I cannot write text within the textarea.

about 4 years ago · Santiago Gelvez
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda