3

I have an iframe that contains a Jquery Terminal. The iframe is hidden and I'll show when I press a button. The problem that I have it's that I must click the terminal to set the focus on it and is a little annoying.

I tried to write a script that set focus to the iframe or some element that exists in the terminal but it doesn't have the focus.

EDIT: I solved the problem. The solution that I've found was this:

$('iframe')[0].focus();
jcubic
  • 61,973
  • 54
  • 229
  • 402

1 Answers1

1

Actualy it's not related to terminal, you need to call focus on window object

$('button').click(function() {
    var iframe = $('iframe').show();
    iframe[0].contentWindow.focus();
});
jcubic
  • 61,973
  • 54
  • 229
  • 402