Reputation:
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
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