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

103
Views
javascript check if a string exists on page

I am working on checking if string exists on page. And I have some difficulties. I have url that generated by system var url = here it generated it in string format and its in "string" format. So lets say it has for of "url/my" and "url/yours" I make it to be url by <a href="@url" target="_blank">@text</a> I need to check if it contains exact word on page in generated url

<script type='text/javascript'>
  window.onload = function () {
    if (document.body.innerHTML.toString().indexOf('something') > -1) {
      alert("It contains 'something'");
    }
  };
</script>

This is working on the page that was opened, but not on the page of the generated URL. I need to make it work in IF-ELSE statement. Something like

if(url contain word "something")
{
  do that
}

So I need somehow pass generated url with href to script and then to if-else statement

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can check url pathname and then make control in your function

let pathname = window.location.pathname

if(pathname.includes('home'))
{
      do that
}
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!