Problem with focus within iframe

S

suit

Hiya,

I'm trying to implement an integrated HTML editor into my application..
but I'm hitting my head against a brick wall trying to get the focus
working the way I want it to within it...

I've produced a simplified version of the editor to demonstrate the
problem (http://hosted.yetanother.net/wtf.html).

- Immediately on loading, I want the focus to be placed within the body
of the iframe.. I don't really care where even.. just so that the user
can start inputting text without having to click within the iframe.. If
you use the dropdown box to insert some text, it'll be placed at the
top of the screen rather than bellow the toolbar.

The strange part here is that sometimes it works.. sometimes it doesn't
(if i keep hitting f5, I can see it sometimes working.. and sometimes
not).. I can't figure out why it is intermittant.. or how to guarantee
that the focus will be where I expect it to be..

I've used so many techniques to try and get the body element within the
iframe and then to focus it.. but none seem to work reliably..

The problem also effects my full editor when I switch between source
and preview modes.. but I've ommited that from the bellow example as I
belive the solution to that will be the same as the one I've just
detailed..

The parameters for this exercise are:
- the editing area has to be an iFrame.
- It must work in IE6.. other browsers aren't supported currently.

If anyone needs any additional information, please just ask.

The code is available at: http://hosted.yetanother.net/wtf.html

This problem has been driving me nuts on and off for a number of weeks
now.. I'm now at the point where everything else is working appart from
this... so if anyone could shed any light on it for me, I'd be much
obliged!

Cheers!
 

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
473,982
Messages
2,570,189
Members
46,735
Latest member
HikmatRamazanov

Latest Threads

Top