2

I am able to get the previous page URL, but also I need to get the URL of the second last visited page.

I have used the below code..

<script>
_spBodyOnLoadFunctionNames.push("GetUrl");  

function GetUrl() {
   var referrer =  document.referrer;
alert(referrer);

//var x=history.go(-2);
//alert(x);
}
</script>

but history.go(-2) will directly redirect to the second last visited page, how to get that url?

  • I am able to get the previous page URL, but also I need to get the URL of the second last visited page. I have used the below code.. <script> _spBodyOnLoadFunctionNames.push("GetUrl"); function GetUrl() { var referrer = document.referrer; alert(referrer); //var x=history.go(-2); //alert(x); } </script> but > history.go(-2) will directly redirect to the second last visited page, how to get that url? – B upender Oct 13 '19 at 6:20
  • I am able to get the previous page URL, but also I need to get the URL of the second last visited page. I have used the below code.. – B upender Oct 13 '19 at 6:22
1

this worked for me..

<script>
_spBodyOnLoadFunctionNames.push("GetUrl");  

function GetUrl() {
   var referrer =  document.referrer;
//alert(referrer);
}

function SecondLast(){
var x=history.go(-2);
//alert(x);
}


</script>
<button onclick="SecondLast()">Click me</button>
|improve this answer|||||
  • Does it prevent you from redirecting? – Atish Dipongkor - MVP Nov 10 '15 at 11:59
  • no, but now I can do it on button click.. – KumarV Nov 12 '15 at 5:07
  • In your question you asked that "how to get that url". redirecting in button click was not your requirement – Atish Dipongkor - MVP Nov 12 '15 at 5:10
1

In general history is protected by the browser against javascript accessing it except through back and forward functionality.

https://stackoverflow.com/questions/13369829/access-my-entire-browsing-history-via-javascript

So you can not access it.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.