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

229
Views
How do I make this url redirection work in Javascript?

need help on setting up redirects if the url has /pages/ in it and is browse using mobile they will be redirected to the following path like this.

google.com/pages/tutorial TO google.com/a/b/pages/tutorial

Here's my code below:

<script type="text/javascript">
if (screen.width <= 699 && url = "pages") {
document.location.href = ''+'/a/s'+ window.location.pathname;
}
</script> 
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Would something like this achieve your goal?

if (document.location.href.includes("pages"))
  document.location.href = document.location.href.replace("pages", "a/b/pages");
about 4 years ago · Juan Pablo Isaza Report

0

Expanding on @async awiat's answer, the following will also check the screen width.


if (screen.width <= 699 && document.location.href.includes("pages")) {
    document.location = "name-of-path"; 
}

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!