473,402 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Determining name of focus() element

How do I determine in JavaScript the name of the object that focus is on?

Jul 20 '05 #1
4 10412


Lasse Reichstein Nielsen wrote:
"steve stevo" <st***@stevosteve.fsnet.co.uk> writes:

"Paul Thompson" <pa**@wubios.wustl.edu> wrote in message
news:bi**********@newsreader.wustl.edu...
How do I determine in JavaScript the name of the object that focus is on?


document.objName.focus()

That would solve the problem, by moving the focus to an object that you
know the name of. I don't think that was what the original poster had in
mind, though :)

By "focus", I assume is meant an input element (like a text field).

There is no simple way of finding the element with focus. What you can
do is to have each input element trigger a script when it gets focus,
and have that script store the element in a global variable. That
way the global variable will point to whatever element has focus.

What is this needed for?
/L


You are 100 % correct. I have decided to set a variable in the onFocus
for each input widget.

What is this for? I have found that using the tab key to shift from one
widget to another works generally. However, when I use focus() to shift
focus to a widget, the use of tab after that is not correct - instead of
tabbing from the last focus object, it tabs from the last TAB event. I
can't figger out why. Have you ever seen this?

Because of this, I am writing an event handler to control tabs correctly.

If you are interested, I can show you a web form which does just what I
said.

Jul 20 '05 #2
Paul Thompson <pa**@wubios.wustl.edu> writes:
What is this for? I have found that using the tab key to shift from
one widget to another works generally. However, when I use focus() to
shift focus to a widget, the use of tab after that is not correct -
instead of tabbing from the last focus object, it tabs from the last
TAB event.
So it doesn't follow the focus directly, but continues from where it
was last time you tabbed?
I can't figger out why. Have you ever seen this?
Nope, but I usually leave navigation to the user, so no fiddling with
focus.
Because of this, I am writing an event handler to control tabs correctly.
It is rarely wise to try and emulate a browser feature in javascript. The
browser should be better at it than your code will ever be.
On the other hand, working around a bug is always "fun". :)
If you are interested, I can show you a web form which does just what
I said.


That would be great. And please say which browser exhibits the
problem, and exactly how to recreate it (yes, I'm lazy :).

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #3


Lasse Reichstein Nielsen wrote:
Paul Thompson <pa**@wubios.wustl.edu> writes:

What is this for? I have found that using the tab key to shift from
one widget to another works generally. However, when I use focus() to
shift focus to a widget, the use of tab after that is not correct -
instead of tabbing from the last focus object, it tabs from the last
TAB event.

So it doesn't follow the focus directly, but continues from where it
was last time you tabbed?

I can't figger out why. Have you ever seen this?

Nope, but I usually leave navigation to the user, so no fiddling with
focus.

Because of this, I am writing an event handler to control tabs correctly.

It is rarely wise to try and emulate a browser feature in javascript. The
browser should be better at it than your code will ever be.
On the other hand, working around a bug is always "fun". :)

If you are interested, I can show you a web form which does just what
I said.

That would be great. And please say which browser exhibits the
problem, and exactly how to recreate it (yes, I'm lazy :).

/L


Use NN, preferably a recent version (6.2 or later; I use 7.1)

go to

http://www.biostat.wustl.edu/~consult/demo/startup.html

Select SCID (the 5th choice), and push WDES Demo Choice

click on Visit and select any one

tab to the next radio button and select ABSENT by hitting <space>

At this point, your focus will be shifted down about 10 rows (follow the
little blue arrow) to the next absent. If you hit <SPACE> again, you
will again be shifted. However, if you hit <TAB>, you will be shifted
back up the screen.

How can I get the <TAB> key synchronized with the FOCUS() ?

Thanks for looking at this!!

Jul 20 '05 #4
Paul Thompson <pa**@wubios.wustl.edu> writes:
Use NN, preferably a recent version (6.2 or later; I use 7.1)
I don't have any recent NN. I tried in Mozilla Firebird 0.6 and
Mozilla 1.5a, which should be comparable.
http://www.biostat.wustl.edu/~consult/demo/startup.html .... However, if you hit <TAB>, you will be shifted back up the screen.
Cannot reproduce the problem, sorry.

I enter the url, select SCID, click the submit button.
On next page, I use the mouse to select an option under "Visit?",
then press TAB, TAB, SPACE (I am now at the absent field further
down the page) and TAB, and end up in Sub-Threshold just after the
previous field.
How can I get the <TAB> key synchronized with the FOCUS() ?


It should work (knock wood).

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Stefano | last post by:
Hi, i want set focus element with element.focus() but i have always this exception: "focus() is not a function" Can you help me? Thanks I use Mozilla
9
by: s_m_b | last post by:
I'm trying to get an <a> element to gain the focus onload, but only get back 'has no properties'. Reading through this ng, its clear that unless the element is within a form, this doesn't happen,...
3
by: VA | last post by:
t=document.getElementById('mytable') is a HTML table with some input fields in its cells Why doesnt t.getElementsByTagName('tr').firstChild.focus; put the focus on that text field? It...
0
by: Vinod. | last post by:
Hi all, I have added browser control to a windows form. I am loading pages having multiple frames. I have noticed that the focus in a text is not maintained when the application is deactivated....
4
by: petermichaux | last post by:
Hi, I'm hoping for a reason I'm wrong or an alternate solution... I'd like to be able to dynamically include some javascript files. This is like scriptaculous.js library but their solution is...
5
by: Bosconian | last post by:
I've hunted high and low, but I can't figure out how to retrieve the name of an element when onclick occurs. <select name="myselect" onclick="alert(this.form.elements.name)"> returns a blank...
2
by: yawnmoth | last post by:
Say I have two input elements and that I wanted to make it so that when the first ones input was what it should be, the focus would automatically be shifted to the next input element. ie....
4
by: Steve Swift | last post by:
I'm trying to give the focus to a field defined with: <INPUT TYPE=TEXT NAME=P.LAST_NAME> and I'm having a spot of bother with that "." in the field's name. I thought that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.