0

I am unable to set the focus to an element inside an iframe.

My page inside the iframe has a div with the id "packagetab2". Inside this iframe I have a Javascript function called by an onclick of an element inside the iframe.

function movefocus(e)  {
window.focus();
document.getElementById("packagetab2");
}

Is there a solution?

Note - this scenario is from inside an iframe.

Vincent
  • 37
  • 2
  • 6
  • Possible duplicate of [Setting focus to iframe contents](https://stackoverflow.com/questions/369026/setting-focus-to-iframe-contents) – Aniket G Apr 10 '19 at 03:44
  • Possible duplicate of [Is it possible to focus on a
    using JavaScript focus() function?](https://stackoverflow.com/questions/3656467/is-it-possible-to-focus-on-a-div-using-javascript-focus-function)
    – 31piy Apr 10 '19 at 04:58

1 Answers1

0

try this:

document.getElementById("packagetab2").focus();