1

Is there any way to get the url of the website the user was on before loading the current website or just a quick way to redirect to it? I understand there is document.referrer but I need something more ubiquitous.

Also, is there any way to get the users browser home page (or any of the browser settings for that matter)? Now, I don't need the exact URL but a means to, for example, a user to click on a button and get redirected to his homepage.

I understand there are many security concerns over this, but really anything will do.

user3525134
  • 123
  • 4

1 Answers1

1
<!DOCTYPE html>
<html>
<head>
<script>
function goBack()
  {
  window.history.go(-2)
  }
</script>
</head>
<body>

<button onclick="goBack()">Go 2 pages back</button>

</body>
</html>

From w3schools

But Why?

toesslab
  • 5,092
  • 8
  • 43
  • 62
  • For UX purposes. I guess I will need to track how many times the user has clicked on a link within the website and then use this number in the back function. Thanks. – user3525134 Apr 18 '14 at 13:56