Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javascript to get url of previous page

I want to get url of previous page. I found a lot of answers but I couldn't find anything which works with back button of browser. I used document.referrer but it also doesn't work for back button. Can anyone help me??

like image 391
ishakya Avatar asked Jan 19 '15 11:01

ishakya


1 Answers

Use the following in javascript snipet

document.referrer;

if you are implementing back button use this

<a href="javascript: history.go(-1)">Back</a>
like image 57
Shashidhar Patil Avatar answered Oct 15 '22 07:10

Shashidhar Patil