I have a chat script which uses window.focus() when there is a new message to highlite the window in the taskbar. It works fine when I use a popup. But when I put the chat application in an iframe and then window.focus() I have a problem with typing in the text. It constantly focuses to the begin of the input field. So when a user sends a message and I type a message then my cursor goes to the beginning of the input field. Is there a way to focus to the iframe and that the window will highlite in the taskbar? Or is there a way to only window.focus() when the window is not active (so when I'm not typing)?
This is what I have now: