Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

167
Visualizações
Detect if user is using mobile iOS

I have written a function to copy text from a textarea but I need to have a particular code block executed if the user is using an apple mobile device.

I tried the following statement

if (navigator.userAgent.match(/iphone|ipod|ipad/)) {
 // code
}

but it doesn't seem to work very well.

Do you have any suggestions?

/* Full code */

function copy(copyText) {
  if (navigator.userAgent.match(/iphone|ipod|ipad/)) {
    // handle iOS devices
    copyText.contenteditable = true;
    copyText.readonly = false;

    var range = document.createRange();
    range.selectNodeContents(input);

    var selection = window.getSelection();
    selection.removeAllRanges();
    selection.addRange(range);
    input.setSelectionRange(0, 999999);
  } else {
    // other devices are easy
    copyText.select();
  }
  document.execCommand("copy");
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Detecting a mobile browser

Not sure if this is what youre looking for but it looks like might have the answer to your question?

Using navigator.userAgentData You may also use navigator.userAgentData.mobile, but userAgentData is still experimental, so it is not recommended for use in production.

const isMobile = navigator.userAgentData.mobile;

That part might be of use

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda