user2088019
user2088019

Reputation:

Set focus to jQuery Terminal that is within an iframe

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();

Upvotes: 3

Views: 1991

Answers (1)

jcubic
jcubic

Reputation: 66490

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();
});

Upvotes: 1

Related Questions