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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking if something is in focus

Status
Not open for further replies.

BatGrrrL

Programmer
Jan 21, 2003
12
AU
Hi Guys,

Could someone please tell me how I can tell if my iframe is in focus? I'm writing a wysiwyg editor using the execcommand in javascript and ie and if the focus is outside of the iframe (on the main page body) then my buttons will write their output to the main page rather than the iframe. I would like javascript to tell me if my iframe is not in focus and pop up an alert asking the user to place the cursor in the iframe.

I could have a focus() command on the iframe before the buttons output but this adds the output to the front of the iframe.

Cheers
BatGrrrL
 
Solved it:

I load currentFocus = '' at startup.

when they focus on my iframe i set currentFocus = 'iFrame'

when they click outisde that it goes back to currentFocus = ''

Yay :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top