一些网站focus
在窗口加载时设置了一个元素。如果我 iframe 该网站,似乎无法以编程方式将焦点设置在父窗口上。这只发生在IE
(9) 和Firefox
(19) 中,Opera/Safari/Chrome 都可以。
<script>
window.onload = function() {
setTimeout(function() {
// this does not focus #foo
document.getElementById("foo").focus();
// or more seconds that enough to see the iframe focus
}, 3000);
};
</script>
<input id="foo" type="text" value="foo" /><br />
<iframe width="800" height="500" src="http://www.bing.com" />
有谁知道这个问题的解决方法?