Go back automatically to previous page - javascript

is there any solution to go back to previous page automatically without reloading the previous page?
I have index.php page full of jquery dropdown list, and after last dropdown list, there is a form to edit data. After editing data and successfully added to database I want to go back to index.php without losing selected dropdown list before.
I try meta http-equiv refresh but no luck. I also try javascript function to call history.go(-1) after specific time but it seems no work also.
It can be done if I create a href link to history.go(-1), but I want it to be automatically.
Any solution for this?

history.go(-1) automatically?
Like this?
I'm feeling lucky
Feel free to connect it to anything, doesn't need to be a button.

Related

About AngularJS pagination (I used localStorageService before but it wasn't the solution i wanted to apply)

First, Thank you for watching this question!
I'm newbie to angularJS and i'm trying to make pagination to be more flexible to use.
Below is my situation.
I made pagination function
It works as my intention
But, When i get into other page(leave list page which includes pagination function), and try to go back, the problem appears!
(Here is what i want to solve) I go back to list page by clicking backspace key or clicking back button on view. and the params i entered in list page is gone!
In multi page application, the url can be '/tt?aid=11&bid=22&cid=33', and i get into detail view page, and i can retrieve to '/tt?aid=11&bid=22&cid=33' by just clicking back button. but in angularjs, it goes back to list page with no params.
And below is what i tried to solve above problem.
I used local-storage-service
I used onPageUnload event(of browser)
I'm not sure if this best fits.
Store the page no.
When you click back to get that list, feed that page no.
page no can be stored in a scope variable.
Your pagination function should be able to give the list based on page no.

Can I keep fields in a form populated even if I move to a different page and then back?

I am currently looking at creating a form using HTML, CSS and a bit of JavaScript. I was wondering though if anyone had any ideas how I could keep all the fields populated?
I want to be able to fill in a form and click 'Next' which will go to a different page with a different form. But if the user presses the 'Back' button to edit some information on the previous page for example, how would I keep all the fields populates?
Bit stumped on this, so any suggestions would be appreciated :)
You may use localStorage or cookies for that purpose to store content of the page on the client' side.
See https://stackoverflow.com/a/27273657/696034 for an example; in you case, you call save() when receiving location change event, and load() on the page' initialization.

How to maintain states of selection on back button

I am using HTML and JavaScript to write Android APP, but I have a problem that when go back from current page to the previous page, the page is reloaded and the selection and setting when I made in the first goes to default.
For example: On the first page user can select country and city and then navigate to second page.
If user clicks on back button (which calls window.history.back(); or href="javascript:history.back(-1);")
, then all the selection he made are lost and default selections are shown.
It works fine in native browser of Android.
How to maintain state of selection?
Thanks in advance!
You need to make dummy history to disable history back button.
var originalHash = document.hash || "#dummyMain"
location.assign("#dummyBack")
location.assign(originalHash)
window.addEventListener("popstate",function(){
if(location.hash == "#dummyBack"){
window.history.pushState(null,null,originalHash)
}else{
originalHash = location.hash
}
});
The code above create dummy page history and checks if page transitions are occurred via history back button or not and if so,force page move to current page again to stop history back action.
Since You didn't put any code in the question,It's hardly possible to say it will work or not but I guess once you load this code,it should disable all page back action.
If you are using PC/Mac to use this site,please try to open developper tools/firebug javascript console and copy/paste the code and press history back button to see how it works.
I find a good way to maintain the data of previous page, which use localStorage store the data as key value before leaving this page and again when come back to this page you can get your data again from localStorage` and display it.
Because the data which is loaded by AJAX will be last on history back.
Hope this help someone may has this problem.

Javascript history go — if not, go to index.html

To go back to the appropriate tumblr page, we're using:
Back
However, we're getting a lot of traffic directly from the twitter app, and this stops the function working. Is there a way so that if the history.go doesn't work (or takes you outside the site), it will just take you to index.html?
This is one of the pages the history button is on: http://lexican.info/post/49265445109/sesquipedalophobia
Thanks for any help at all.
Sadly I don't think this is possible as there is no relationship between a post and what page of the index the post is displayed on.
Try to check how many page in the history list with history.length:
http://www.w3schools.com/jsref/prop_his_length.asp

Classic ASP - How to pass a variable instead querystring (refresh) via Jquery(no refresh)

i'm working on this application that has a calendar on a page that has a lot of request.form("var") inside.
This is a monthly calendar and it has on the top previous month and next month .
When i click now on next month i get an URL like: ?date=8/14/2010
My question is how to pass this value to the calendar via jquery with no page refresh .. because if i use page refresh i loose the request.form("values")
Hope i make myself understand ,
thank you
If you use AJAX, you can send requests and get information without refreshing the page. As far as I know, JQuery has some functions built in to make AJAX pretty easy.
Another common way this is done is to use the anchor rather than the query string (e.g. http://example.com/page.asp#8/14/2010), because then you can still link directly to the page as it is, and changing the anchor doesn't cause the page to refresh and can be red by JavaScript. GMail and Facebook both use this, which is why you can scroll through pictures fast without reloading the page for every picture.

Categories

Resources