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

172
Visualizações
Use .indexof to Check for Multiple Strings with Array

I am attempting to embed a chat widget if utm_source=VALUE (any of these values)

Here is the surrounding code:

var ref1 = document.referrer;
IF STATEMENT HERE
  {
    alert("Welcome to Ellas Bubbles");
    s1.src='https://embed.tawk.to/620675459bd1f31184dc28c0/1frkjk5mj';
  }

You can test it here: https://ellasbubbles.com

I have tried the following, which is only working on 'ccov':

if ((ref1.indexOf('ccov') || ref1.indexOf('top10') || ref1.indexOf('cenf') || ref1.indexOf('aip') || (getcookie('track-page-1').indexOf('ccov')>-1) || (getcookie('track-page-1').indexOf('top10')>-1) || (getcookie('track-page-1').indexOf('cenf')>-1) || (getcookie('track-page-1').indexOf('aip')>-1)) > -1)

I have also tried this:

  if ((ref1.indexOf('ccov' || 'top10' || 'cenf' || 'aip') || (getcookie('track-page-1').indexOf('ccov' || 'top10' || 'cenf' || 'aip')>-1)) > -1)
  {
    s1.src='https://embed.tawk.to/620675459bd1f31184dc28c0/1frkjk5mj';
  }

Which is also only working on the first value, 'ccov'.

I have also tried this:

if ((ref1.indexOf('ccov', 'top10', 'cenf', 'aip') || (getcookie('track-page-1').indexOf('ccov', 'top10', 'cenf', 'aip')>-1)) > -1)

Which is also only working on the first value

Is there a better way to go about this?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I think your statements are incomplete. Before each || you need to condition to be satisfied. I’m writing on my phone so sorry this isn’t as specific but you need the >-1 before every ||. So instead of X || Y < z I think You need X < z || y < z.

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