473,785 Members | 2,374 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 10440


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

"Paul Thompson" <pa**@wubios.wu stl.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.objN ame.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.wu stl.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.wu stl.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.wu stl.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
1645
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
9512
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, but according to the w3 TR on html 4.01, the a element can take onFocus commands, which to me means you can do document.getElementById(element).focus() ? I'm trying to get the focus to a specific paragraph, so the page scrolls to it on loading,...
3
6897
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 doesnt give any errors, the focus just doesnt change.
0
2117
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. I fixed this issue by finding the active element in dom and then setting its focus. If the active element is a frameelement then I get the document of the frameelement and then get the activeelement of that document and set the focus. This works...
4
2165
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 broken in Firefox 1.5.0.1 on OS X. What happens with the Scriptaculous library is this In the html document the author only has to include one line
5
1392
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 alert box. Can someone clue me in? Thanks.
2
55409
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. something like... <input onkeyup="if (this.value.length == this.maxlength) document.forms.elements.focus()" value="whatever" maxvalue="x" type="text" /> <input value="whatever" maxvalue="x" type="text" />
4
3821
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 document.FormName.P\.LAST_NAME.focus() should do the job, but it doesn't. I've tried a number of variations, with no success, so far. I could recode my application to use a character other than "." in that element name (yes, I was asking for trouble) but I'd prefer...
0
9646
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10157
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10096
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9956
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8982
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7504
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6742
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5514
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4055
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.