0

how can we determine if window.history is from a certain URL like www.example.com , and then do something for example :

if ( //window.history includes example.com string ) { $('.myclassname').hide() }

it actually needs to know the link location of history ... is there any way to find it out ?

Payam Shakibafar
  • 1,115
  • 3
  • 12
  • 25

1 Answers1

0

You can only get the referer(the page user came from) via document.referer. You can't access history from js.

Heavy
  • 1,861
  • 14
  • 25
  • with document.referrer, how can we extract the URL of the previous page in which a user was ? – Payam Shakibafar Feb 05 '13 at 12:33
  • `alert(document.referrer)` – Heavy Feb 05 '13 at 12:37
  • I tested that before, it alerts a blank popup while first I go to google.com and then go to my html link... – Payam Shakibafar Feb 05 '13 at 12:39
  • User should **click** the link to pass referer. If you visit google, then just paste link into address bar, referer will be empty. By the way, google uses anti-referer protection. – Heavy Feb 05 '13 at 12:57
  • about google yeah u are right. but about the link, I have 2 html files, index.html & single.html. I've put single.html link in index.html. first i go to index and then click on the link of single page.. but still the alert is blank ... – Payam Shakibafar Feb 05 '13 at 13:06