John Cena
John Cena

Reputation: 45

How can we see "Previous Page Result" if user go from one page to another & another

Suppose I have an application in which user searching an item & then search that item category , subcategory & availability in country. Or next he search another item "So now I want to set a button(See Previous result) & by clicking on them he checked all his previous searched result. " Same as all browser back button works.

So kindly suggest me how can I do that. Any suggestion really appreciate.

Upvotes: 3

Views: 97

Answers (3)

Gnanz
Gnanz

Reputation: 1873

You can access browser history from javascript using history object

window.history.back()

will bring you one step backward(previous page) and

window.history.forward()

can access next page from there.

length will returns the number of URLs in the history list.

Example:

<script>
function goBack() {
  window.history.back();
}
</script> 

<input type="button" value="Back" onclick="goBack()">

Upvotes: 0

John
John

Reputation: 707

Please try this solution :

<script type="text/javascript">
function goBack()
{
window.history.back()
}
</script>

<input type="button" value="Back" onclick="goBack()">

The back() method loads the previous URL in the history list. This is the same as clicking the Back button or history.go(-1).

Upvotes: 1

You can store value to browser sessions and reload the page if session have value then get from session or from your search result.

Upvotes: 0

Related Questions