Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking For Image with the Focus

Status
Not open for further replies.

clydejones

Programmer
Jan 11, 2001
153
US
Hi All,

I'm kinda new to JavaScript. How can I check to see if an image has the focus?

Thanks,
Clyde
 
Code:
<img src=&quot;C:\Windows\Triangles.bmp&quot; onFocus=&quot;alert('I have focus')&quot; tabIndex=&quot;0&quot;>
 
Supra,
Thanks for the reply. Let me be a little more detail in my situation. I have two images. Within each image tag I have onClick = &quot;showFocus()&quot;. I am going to the showFocus function, but once I get there, I want to increase the border of the image I clicked. The code I have for that is:

if(document.frmName.imageName1.Focus = &quot;True&quot;)
{
document.frmName.imageName.border = &quot;35&quot;;
}
else if(document.frmName.imageName2.Focus = &quot;True&quot;)
{
document.frmLineupWorkspace.imgImage2.border = &quot;35&quot;;
}
I always increase the border of the first image no matter which image I click. I never increase the imageName2 even if I click it first. I believe I'm blowing it in the if statement, but I'm not sure where to go from here or if the statement is totally correct. Once again, thanks for your reply. Any further suggestions would be appreciated.

Clyde
 
hie

>>if(document.frmName.imageName1.Focus = &quot;True&quot;)
should be imageName1.Focus == &quot;True&quot;)
.. i guess..
:)
 
Vituz,
Thanks for your reply. I went another route that works. I tried you code, but didn't get the result I was expecting. Nothing happened. Thanks Again.

Clyde
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top