Finding the name of the element selected

A

Anthony P

Is there an easy way to find the name of the form element that has
current focus? For example, if I want to insert something into
whatever form field the user happens to be on, but I don't know that
field name, how can I find that information out?

I ask because I'm writing a plug-in.

Thanks!
Anthony
 
M

Martin Honnen

Anthony said:
Is there an easy way to find the name of the form element that has
current focus? For example, if I want to insert something into
whatever form field the user happens to be on, but I don't know that
field name, how can I find that information out?

IE has
document.activeElement
Firefox 2.0 does not support that however. Firefox 3.0 will support it.
Opera 9 does already support it.
 
T

Thomas 'PointedEars' Lahn

Anthony said:
Is there an easy way to find the name of the form element that has
current focus? For example, if I want to insert something into
whatever form field the user happens to be on, but I don't know that
field name, how can I find that information out?

<script type="text/javascript">
var focusedName = "";
</script>

<input ... onfocus="focusedName = this.name;" ...>

There is no other interoperable way.
I ask because I'm writing a plug-in.

Would a plugin not have access to the full API instead?


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,085
Messages
2,570,597
Members
47,218
Latest member
GracieDebo

Latest Threads

Top