简体   繁体   中英

Getting website before or home page

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.

<!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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM