Link to home
Start Free TrialLog in
Avatar of mehran
mehran

asked on

Identifying current active element

How can a javascript function identify the current active element in a document?

for instance in the following code what should I put inplace of activeOBJ?

<HTML>
<BODY>
<FORM id="frm" action="something">
  <INPUT id="input1">
  <INPUT id="input2">
</FORM>
<SCRIPT type="text/javascript">
function handler(e);
{
  if (activeOBJ == "input1") {
    dosomething();
  }
}
document.onkeypress = handler;
</SCRIPT>
</BODY>
</HTML>
ASKER CERTIFIED SOLUTION
Avatar of newjack
newjack

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 Michel Plungjan
Methinks you mean this and not self

Michel
Avatar of mehran
mehran

ASKER

event.srcElement.name was what I really look for.
Which is e.target.name in Netscape
Avatar of mehran

ASKER

thanks mplungjan, but I asked this question twice, once in html folder and other one in javascript folder.

and I got my answer in the other side(folder).
No problem

it is indeed this and not self, I happened to come across it myself today :)