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

154
Vistas
document.getSelection() not working on iOS chrome/safati

The problem that i'm having is that on iOS it seems like i cannot get the selection from the textarea. The same code on PC works well, and i can see the same text in the two alerts (range and sel, see code): on iOS unfortunately I see what i expect iun the 'range' alert but i see nothing in the 'sel' range (just the actual "sel :").
I tried almost every type of check possible and read all the existing documentations (i think at lest) before writing here so this is kinda my last resort

also the code is crappy, im sorry, just need this to work on mobile

                    // text area method
                    let textArea = document.createElement("textarea");
                    document.body.appendChild(textArea);
                    $(textArea).html(textToCopy);
                    // make the textarea out of viewport

                    textArea.style.position = "absolute";
                    textArea.style.opacity = 0; //tried without this, didnt work
                    textArea.style.left = "-999999px";
                    textArea.style.top = "-999999px";

                    //tried with this, didnt work
                    textArea.contentEditable = true;
                    textArea.readOnly = false;

                    $(textArea).css("user-select", "text");
                    $(textArea).css("-webkit-user-select", "text");

                    /*textArea.focus();*/

                    var selection = document.getSelection();
                    var range = document.createRange();
                    range.selectNodeContents(textArea);
                    alert("range: " + range)
                    selection.removeAllRanges();
                    selection.addRange(range);

                    alert("sel: " + selection.toString())

                    //tried with this, didnt work
                    /*textArea.setSelectionRange(0, 999999);*/

                    document.execCommand('copy')
                    textArea.remove();
about 4 years ago · Santiago Trujillo
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