I have an iframe that has its own application. I want to be able to focus a target outside the iframe but so far it's not recognizing it. On the page itself, it works, but once inside the iframe ( text area ), I want to shortcut out of the iframe. The function works inside the iframe ( console.log works at least ) but not the actual focus event. I tried to focus on the document first and then have it run the action, but it is not focusing outside the iframe. I have to have the function in the application so that it recognizes it.
https://jsfiddle.net/5ufc4koc/
<div class="field">
<a href="#">Testing</a>
<iframe>
<div>Text text text
</div>
</iframe>
</div>
App.outside = function () {
$(document).focus();
$(document).on('keydown', function (e) {
if (e.which === 113) {
$('.field:first a').focus();
console.log('testing');
}
});
};