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

158
Views
Javascript get the full URL that redirected to a page

javascript refereer image explained

Hi there, as you can see on the image, in my webpage I have several pages that can redirect to the same page. On the example, both pages:

example.com/content.html -> example.com/news.html
example.com/files/actual.html -> example.com/news.html

I want to enable a button on the page example.com/news.html which goes back to the full source refereer url

So for example, if user A got redirected to example.com/news.html through example.com/content.html his Go back button should point to the source URL -> example.com/content.html

I have tried the JS property

var referrer = document.referrer;
console.log(referrer);

But It only returns the domain name example.com and not the full URL example.com/content.html

Any thank is appreciated.

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

0

What you are asking for is not possible. In modern browsers, a redirect does not replace the referrer, nor does the redirect appear in window.history. Using client side JavaScript, there is no way to tell that the user came through a redirect as opposed to clicking on a link that brought them to the page directly.

As a workaround you could change the redirect to add a parameter. example.com/content.html could redirect to example.com/news.html?from=content.html Then the JavaScript on news.html could look at the URL parameter to determine which page redirected.

Alternately, you could use server side solutions. Your server's access log would have a record of redirects. You could examine this log file to determine which page redirected.

about 4 years ago · Juan Pablo Isaza Report

0

It depends on what you need. If you always have a redirection you can use :

window.history.go(-2);

Otherwise, you may have to manipulate the parameter using history informations.

Full documentation : https://developer.mozilla.org/en-US/docs/Web/API/History_API

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!