iframe中的document.activeElement在IE标准模式下显示未指定的错误

Bal*_*ath 6 javascript internet-explorer

console.log(document.activeElement);
Run Code Online (Sandbox Code Playgroud)

此代码位于iframe中,当打开包含此iframe的页面时,在IE 8/9标准模式下显示"SCRIPT16389:未指定的错误".在怪癖模式下打开时没问题.我对此毫无头绪,我搜索了IE是否支持document.activeElement,其指定为> IE4是否受支持.

Rin*_*nku 8

检查下面给出的链接,如果它可以帮助你..
Link


muz*_*amo 6

如果您有jquery,请尝试以下解决方法:

<script>
         jQuery(function () { document.documentElement.focus(); });
    </script>
Run Code Online (Sandbox Code Playgroud)