I've a page where you fill a form to search on YouTube API and returns some videos with buttons to go to another page with details about the video. Then there is a button to go back to previous page, but when clicked it returns the page as was open (Without any results). Is there a simple way to load the page with this results?
You can save the search key in session storage when the user clicks the video button. That way you can always get it back when you return to the previous page.
Related
I have a page where you can search rates using location and dates. Once you get to the confirmation page I have a link to go back and select a different rate. By using history.go(-2) I can go back to the rates page fine. But I were to right click open or wheel click, it just goes to the home page, because the search criteria is not saved.
How do I go about fixing this?
<u>select a different rate</u>
Thanks guys. I ended up using href=document.referrer. That seems to be doing the trick!
Browser history cannot be inherited by a new tab, as far as I know.
You can, however, pass the previous page URL to the new page as a URL parameter, for example:
domain.com/newPage?oldPage=http%3A%2F%2Foldpage.com
You can then modify the browser history when the new page loads, adding the previous page. See Manipulating the browser history
Is it possible to implement this behavior:
I have a HTML link on one page, and after a user clicks on it, it goes to another page which has several tabs on it. Upon clicking on one of those tabs, it triggers an AJAX post call which populates and displays content for that tab.
I would like that when a user clicks a link on the previous page, it takes him to another page and automatically clicks a specific tab so it triggers an ajax call which displays the content for that tab.
This site is a Wordpress site, if that information helps at all.
On the 'from' page you can have links such as
Click Me
You can set an onpage load function to load and use a trigger like this
if(window.location.hash === "#customHash"){
//my custom tab loader
}
You can use jQuery Cookie plugin to achieve this. http://plugins.jquery.com/cookie/
You just set the cookie on the first page, when the user clicks on the link
$.cookie('the_cookie', 'the_value');
And on the next page use the jQuery on load function to check for the cookie.
I'm using jQuery Mobile (no php or xml or anything else) for a web application running on cherrypy and i would like to find out how can i keep the page as it has been set by user even after refreshing.
As an example of the page, see this fiddle: http://jsfiddle.net/xaKXM/5/
in this example, user may input certain text in Response number and description. When the user click submit,user will see #configtable div. if the page is refreshed, user will not go back to the initial page (#labels div' )but to remain in the#configtable` (the one that user can't input anything but can only click activate button")
May be there is a button that would clear all those states and the page will go back to default when refresh?
Is this possible to be done?
if you refresh the DOM using window.open('index.html'); this should clear everything in the page
I am creating a web application.
I have a landing page which the user sees after logging in.
From the landing page they can click a link to go to detail page.
The detail page loads data for the default id to start with. It also contains a drop down for user to pick a different id. When user presses submit button it makes a get request to the same page, but uses the optional argument id=someID this reloads the page and shows the data for the newly selected id. All of this is working correctly.
My question is, if user chooses a few different ids from the drop down and clicks submit to view their data, now if he wants to get back to landing he has to go back through each id that he viewed. I would like to know if it is possible to set it up so that when they press back button they will go directly to landing page no matter how many times they've chosen new id's to view data for.
Here is the flow I'd like to achieve:
/landing -> /detail -> /detail?id=1 -> /detail?id=2 -> [press back button] -> /landing
Have the requests on the details page pulled in via ajax. You have to do some refactoring so that on a successful request, the information it receives will repopulate like a content block, but this will allow the information on the details page to update without you actually navigating to a new page. Then it'll leave you the ability to press the back button to go back to the landing page.
If you're already using a way to catch the amount of id's requested:
<INPUT Type="button" id="back" VALUE="Back" onClick="history.go(-"number of id requests");return true;">
i am creating a page with back button in corner. if the page launched for first back button should hide. if user navigates through page back button should show.
i used the code
(window.history.length > 1)?$("#back").show():$("#back").hide();
but my problem is,
window.history.length is keeps increasing.
But my requirement is when there is no page to go back then back button should hide again. how to achieve that?
you have more problems. what if the user came from google? there would be window history already. What if a user went to your site, then went to google, then came back?
If it's just a nav system as described by #Marc B, it's easy, you know where the user came from and how to get back (don't use the history directly). But if it is a back button no matter what link the user clicks into your site... it gets more complicated. Due to privacy restrictions, you can't access the user's actual URL history (just the length) and you can't access whatever url they are navigating to if you use capture the window.unload event. So you're left with limited options.
One option would be to record the window location on every page load to an array that you keep in either local storage, or a cookie. Then you should use this array to manage your history state rather than relying on window.history. When the user clicks your back button, you just pop off the last url on your site they visited and navigate them there. Keep in mind the first page load will put an item into your history array, so depending on where you check to see if you should show or hide your history button, you'll compare the length of your history array to either 0 or 1.