1

I used window.history.go(-2) it redirects but I don't want to redirect I want to print the URL (to know the referrer), Example: I'm navigate file1->file2->file3, I wrote the script window.history.go(-2) in file3, and I want the alert as 'file1'. Can anybody help me please?

If not possible is there a way to get the referrer URL, and I'm in a iframe, from the frame I want the sites referral URL.

Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592
Madhuri
  • 23
  • 1
  • 8

2 Answers2

0

It is a violation of privacy and it is not possible easily. You can read this to check the history of similar attempts. Nowadays it is way harder.

Leonidas
  • 526
  • 11
  • 20
0

It is possible to go back the browser history via history.go, but not to get the url locations from it. However, if you click some link and entered the page, you can use the document.referrer property to get the referrer url. Refer this link for more info.

Difference between document.referrer and window.parent.location.href

Community
  • 1
  • 1
aarjithn
  • 1,151
  • 8
  • 20