Link to home
Start Free TrialLog in
Avatar of SRO_TSG
SRO_TSG

asked on

Javascript and Focus

Hi,

I have a question regarding how to set the focus to a specific "spot" on a new page.  

I will go to AAA page first.  AAA page is usually long with vertical scroll bar.  It has a list (bullet points) of texts.  I can make the texts <div> with anchors.   Users can use scroll bar or page Up/Down to go to any spot on AAA page.  Then users have a button on AAA page to go to BBB page.  This BBB page has the same list (bullet points) of texts, but in another language.  This means the lengh of the texts (bullet points) might be very different on the two pages.

We wish to put the focus roughly at the same bullet point on BBB page when user leaves AAA page.  Since users do not really have a focused control when they move from AAA to BBB, it seems we cannot track where they really are (at AAA page).  Or can we?  

Is there a way to do this?  Thanks for any help.

TSG
Avatar of ObiRenoKenobi
ObiRenoKenobi

I'm not sure of your question. Do you mean that when a client switches from page A to page B (in your site the both of course) in the B page he must be taken automatically to the same spot that he was in page A?
You can use the # sign within html element/form tags to send the focus.
ASKER CERTIFIED SOLUTION
Avatar of programmer1024
programmer1024

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Before redirecting the user from page AAA to BBB, you will need to keep track of the last element being focussed by the user on AAA (by using the onFocus() event of every focussable element), pass it alongwith request, and then map it to the corresponding item on BBB and set focus on it. You can achieve it by keeping same element names on all the pages or by providing some kind of mapping.
Avatar of SRO_TSG

ASKER

Thanks a lot for all the suggestions!!

I think the problem I have is that users might not have a "focusd" element.

On Page AAA, I have a list of bullet points (all texts).  I will give each one an anchor tag such as A, B, C.  Then users can use scroll bar or Page Up/Page Down to scorll on the page.  Users do not need to user Tab or Mouse to "focus" on any thing on the page.  Then users will clik a button which is actually on a seprate frame to make Page AAA go to Page BBB.   When users use scroll bar or Page Up/Page Down to read the html page,  is there actually a focused element?   I might be able to track the distance users scroll down from top, but since Page BBB is in another language, the lenght of the texts might be very different.  Forcing the focus to scroll down certain distance might not have focus "arrive" at similar spot.

Thanks!!

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SRO_TSG

ASKER

Hi,

Thanks for the great hints.  I think Basilisci's solution is of great help for this approach (find the position of the scroll).  However, since Page BBB might be in a different language, the position might be very different.   The comment from muktajindal is our concern too.

Page AAA will have a list of bullet points (say i, ii, iii, iv, v, vi, etc).  Users scoll to view these points.  Each point has very different length.  If users scroll down to see roughly point iii, then they press Page BBB, we wish Page BBB go to point iii.  We actually have a few different languages, including Asian languages.  So using the scroll posiiton might not make the page arrive at that "point" users are reading at Page AAA...

But this hint is very very helpful for future reference.  Thanks a lot!!

TSG