Menu

How do I set focus on codepress iframe?

2008-08-18
2013-04-24
  • Sony Santos

    Sony Santos - 2008-08-18

    Hello!

    I need to set focus on a codepress iframe via javascript, but I haven't get success.

    I've tried (texto is the codepress iframe object):

    texto.focus();
    texto.firstChild.focus();
    texto.editor.getEditor().focus();
    texto.parentNode.focus();
    texto.previousSibling.blur();  // with the TAB key I get focus, so...
    texto.editor.insertCode('\u2009', false);  // trying to force caret to appear...

    Does someone have some idea?

    I'm in FF3.

    Regards,
    Sony

     
    • Sony Santos

      Sony Santos - 2008-08-18

      I did it!

      texto.contentWindow.focus();

      It was missing some iframe issues to my skills.

      Next challenge: try to set caret position at end of text when getting focus.

       
    • Sony Santos

      Sony Santos - 2008-08-18

      Forgot to mention: in my code it worked better after some time, eg:

      setTimeout('texto.contentWindow.focus()', 100);

      but it's enough for me!  :)

      Sony

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.