Going back to previous page, maintaining data - javascript

I have a search page, where once I input some parameters, I get search results back. Some of the values have links in the results, when I click on them it will route me to another page. I have a back button on the new page where if I click it, I want it to go back to the previous results page with the search results still present.
Is there a way to do so in Angular cli?

Related

Back to previous page instead of previous url in next js

I faced a problem where I have some filters on a page. When you filter, the page URL will change and the query string will add to the end of the URL.So when you click on the back button, the page will stay on the current page and will back to the previous query string. What I want is to get back to the previous page which is come from that to the current page.
For example, I am on /home page, then I go to /browse page, then I filter some items and my URL will /browse?subject=2 and I filter again and the URL will be changed to /browse?subject=2&vendor=2. Now I want to the previous page (I mean /home), when I click on the back button I will go to /browse?subject=2. I hope I have conveyed what I mean.
What you need to do is in your /browse page when you are filtering use router.replace instead of router.push in this way, your filter result won't be added into the browser history and when you try to use router.back you would go to the previous page.

Go back to previous page regardless of changes in query string

I have a page with a searchable table. I have written a "Back" button to go back to the previous page:
Back
For example, the URL of my homepage is:
https://xxxxxx.com
I enter the page with a searchable table from my homepage (Or any other page):
https://xxxxxx.com/data
When I preform a search, the URL becomes:
https://xxxxxx.com/data?search=*sth*
When I hit the "Back" button, the URL becomes:
https://xxxxxx.com/data
What I actually want is:
https://xxxxxx.com/
(Or the page where the user comes in before /data)
How can I rewrite my javascript on the search button, so that the Back button can get to the actual page?
Instead of history.back(), which goes back only by one, you could do window.location.replace(window.location.host), which loads the root page.
To get more info on window.location: https://developer.mozilla.org/en-US/docs/Web/API/Window/location
Edit:
If you want to ignore URL parameters, you need to change how you go to another page.
Instead of window.history.pushState(...), you should use window.history.replaceState(...), when the navigation should be ignored on a back click.
Here more to read on that topic: What is the trade off between history push and replace?

Restore page and state on browser back button

Description
I'm using React.js with server side rendering using Next.js framework
I have "Search" page, which state is initialized using getInitialProps (loads data from API server), and "Object" page.
User can navigate from Search page to Object page, using simple <a> tag.
On search page user can filter data, each filter do new API request and recieve new data.
The problem
After filtering on Search page, user click on item and goes to Object page. Then user clicks browser Back button.
What is now - I got the same search page which was on first load without filtering. Can anybody explain how it is restored and what exactly is restoring?
What I need - I need restore html and state which was after filtering.
How can I achieve this?

Back button when pagination is used in table?

In my angular js application i am using pagination in user list page,through which i am getting ten users at a time from server,and clicking on second page another ten users and so on.Details of a users are listed in a table.Now when click on some user,profile of a selected user is open in another page. Now when i come back from user profile to user list my table is again start from current page one.
That's the issue i want when i come back from user profile , user list must be open from the page where i was.
There are some way that you can fix it.
I recommend you two way.
First:
Change hash in your url when your table page changed and detect hash when you come back to your page.
like this url
http://youraddress.com/subdirs#page=2
You can find how change and detect hash in this link: https://docs.angularjs.org/guide/$location
Second:
Open user page in ajax div with $http in angularJS.
https://docs.angularjs.org/api/ng/service/$http

jQuery mobile remember history with back button

I created an application with jQuery mobile. There is a list of fields that will select a page or another as the sum of their values on different pages.
At the head I have put a navigation button back, but resets the values and results of the previous page.
I would like if the user pressing the back button returns the previous page maintained values and results if you want to modify any of the select.
Is there a way to remember history by pressing the back button?
Code back button:
AtrĂ¡s

Categories

Resources