mikeebee8 — 2011-09-30T07:00:24-04:00 — #1
I am using a script called RecoverScroll which returns the page to its last loaded point when reloaded.
I am using it on a form page, I need it so that...
When the page errors and a div with an ID of #error-box is present in the markup the RecoverScroll script is ignored and the page jumps to #error-box (which isn't in the url)
alternatively, if I could append #error-box to the url if the #error-box div exists in the markup using js I could use the scripts functionality as intended.
The code to run the script...
Any help will be appreciated, many thanks.
mikeebee8 — 2011-10-03T10:38:13-04:00 — #2
Hi all, has no-one got any ideas on this one?
silkster — 2011-10-04T14:00:49-04:00 — #3
RecoverScroll might seem slick, but with forms you just need to set focus to a field and the page will scroll to it; maybe write a JS method to "pad" the position so it scrolls to a point above the field, possibly so the field label is visible. Alternatively, if you want to scroll to a particular element, then just find the position and scroll to its top/left offset.
I know this answer doesn't help with RecoverScroll, but you might do well to reevaluate its usefulness.
mikeebee8 — 2011-10-04T18:29:38-04:00 — #4
Thanks for the reply Silkster. In this case due to some bad functionality (which I can't change at this point), the page reloads when some form fields are actioned. The page is set up to focus and move to certain fields but it makes it makes for a bad UX as the page is jumping (and scrolling to them is not much better) so I've installed Recoverscroll to remedy this which works great.
I just need to remove the Recoverscroll functionality IF a div with an ID of #error-box is present in the markup. That or append it to the url in which case I can use Recoverscroll in that instance too. Hope someone can help : )
If anyone needs anymore information let me know.
mikeebee8 — 2011-10-10T07:22:07-04:00 — #5
Hi all, apologies for the bump. Is what I am trying to achieve possible? This is quite urgent now and I will need to look for an alternative if this cannot be achieved.
mikeebee8 — 2011-10-14T04:34:11-04:00 — #6
Could anyone point me in the right direction with this one?
In a nutshell, this is what I need.
IF #error-box doesn't exist
Run recoverscroll (the script from the top message)
IF #error-box does exist
Don't run recoverscroll/do nothing
I hope this makes sense.