Skip to content Skip to sidebar Skip to footer

Make Sure Iframe Is Selected Right Away

This is possibly a stupid question, but when I'm using an iframe, particular aspects (controlled by event listeners in the html file that is used by the iframe) are available if yo

Solution 1:

<iframeid="iframe"autofocus="true"src="page.html"></iframe><script>document.getElementById('iframe').focus();
</script>

The autofocus attribute in HTML5 can also force an element's focus. In this example, it's redundant.

Solution 2:

try:

iframe.onblur = function() {
  iframe.focus();
}

Post a Comment for "Make Sure Iframe Is Selected Right Away"