Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

170
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!