如何改变iframe的焦点?

如何改变iframe的焦点?

问题描述:

获得一些加载输入框的代码,然后在 iframe 下面加上 textarea ...问题是我希望在页面加载时将焦点放在输入框中,但它始终跳转到 textarea 因为iframe加载了第二个...

Got some code which loads an input box, and then below this is an iframe with a textarea... Problem is I want the focus to be on the input box when the page loads, but it always jumps to the textarea because the iframe loads second...

如何关注页面中的第一个元素?

How do I keep focus on the first element in the page?

将它放在iframe代码中。

Put this inside the iframe code.

<script language="text/javascript">
window.parent.document.getElementById("idOfInput").focus();
</script>