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

142
Views
Can't redirect to url by javascript function

I need a button, which lead up in url path like this:

from /host/elements/1 to /host/elements

I have a link in my html:

<a href="javascript:go_backward()"> </a>

And a javascript function:

function go_backward() {
    var url = window.location.href;
    var page = url.substring(0, url.lastIndexOf('/'))
    window.location.assign(page);
    return false;
}

But when i click the button i only get desired url printed, without correct redirect. Why cat it be so?

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

0

Change:

window.location.assign(page);
return false;

to

window.location.href = page;

If you just want to go back you can also use:

window.history.go(-1)
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!