stressfreewebs
asked on
Indicate the link that was clicked when users clicks back button
Hello Experts!
I have a long list of contacts - clicking on a contact, takes the user to a page where they can view the contacts details. When the user clicks "return to list", I look up the value of a cookie to determine the last viewed contact and highlight them by applying a CSS class to that row of the list.
However, often the user will then click back button on the browser rather than my link.
Is there anyway we can get the record to be highlighted? I have tried setting the selected row via the following jquery:
However, this only reverts to the state the list was in when originally loaded, rather than showing the last clicked item.
I've also tried preventing default on the click, adding the highlight class and then redirecting the users - however again, when back is pressed, we return to the page in its original state.
Is there a way around this?
I would prefer not to disable cacheing if possible (but if that's the only way, I'll have to do it that way).
Thanks,
Dan
I have a long list of contacts - clicking on a contact, takes the user to a page where they can view the contacts details. When the user clicks "return to list", I look up the value of a cookie to determine the last viewed contact and highlight them by applying a CSS class to that row of the list.
However, often the user will then click back button on the browser rather than my link.
Is there anyway we can get the record to be highlighted? I have tried setting the selected row via the following jquery:
target = $.cookie("lasteml");
$(".current").removeClass("current");
$("#"+target).addClass("current");
However, this only reverts to the state the list was in when originally loaded, rather than showing the last clicked item.
I've also tried preventing default on the click, adding the highlight class and then redirecting the users - however again, when back is pressed, we return to the page in its original state.
Is there a way around this?
I would prefer not to disable cacheing if possible (but if that's the only way, I'll have to do it that way).
Thanks,
Dan
ASKER
Hi Leakim,
We don't really want to disable functionality...but the lack of workarounds is making me think what we would like to achieve might not be possible without disabling caching so that the page is forced to reload.
Dan
We don't really want to disable functionality...but the lack of workarounds is making me think what we would like to achieve might not be possible without disabling caching so that the page is forced to reload.
Dan
Just to check and debug, try to print out the value of your cookie in the console like this:
This will tell you if you're retreiving the right cookie value, or if the value is set correctly in the cookie.
target = $.cookie("lasteml");
console.log(target);
This will tell you if you're retreiving the right cookie value, or if the value is set correctly in the cookie.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks mcNute,
That's cleared it up so I'll take my earlier solution as the best option for me here because disabling the cache server side will intervene to reload at an earlier point.
Thanks
That's cleared it up so I'll take my earlier solution as the best option for me here because disabling the cache server side will intervene to reload at an earlier point.
Thanks
ASKER
Most suitable solution
http://stackoverflow.com/questions/7816195/how-to-disable-back-button-in-browser-when-user-logout-in-classic-asp