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

171
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
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