Reputation: 349
I have a search page in my app that produces results containing links to other app pages (local only) when I type search terms into an <input>
field - the usual search behavior. The anchors on the search page look like the following:
"<a href='#/learn' target='_parent'>Go to the Learn page</a>"
If I click the Go to the Learn page
link, it navigates to the Learn
page as expected. Hitting the browser back button, takes me back to the Search
page, but the input field and search results are empty.
I do not want to open a new window, or tab. Instead, replace the window contents with the linked page, then go back to the results that got you there, and try a different link.
How to restore those values?
Thanks, Bob
Upvotes: 0
Views: 170
Reputation:
Use:
localStorage.setItem('oldForm', [document.getElementById("input-id"), "..."]);
window.onload = function () {
var input1 = document.getElementById("input-id");
input1.value = localStorage.getItem("oldForm")[1];
//...
}
It should work
Upvotes: 1