使用 Zend Form 专注于 Textarea
我已经使用 Zend Form 构建了一个表单,并且希望在页面加载时将焦点放在表单内的文本区域上。我尝试使用 JS,有时它会显示焦点半秒,但在实际输入任何内容之前它会删除焦点。
我认为 Zend Form 可能会阻止焦点,所以我查了一下,发现了自动对焦属性选项,但这也无济于事。
知道可能是什么问题吗? 谢谢
I've build a form with Zend Form, and would like the focus to be on a text area inside the form on page load. I tried with JS, sometimes it shows the focus for half a second, but it removes the focus before one can actually type anything.
I thought Zend Form may prevents the focus, so i looked it up, and found the autofocus attrib-option, but that won't help either.
Any idea what the matter may be?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
自动对焦似乎工作正常,但 IE 不支持它。所以你现在可能还停留在 JavaScript 上。
我在 Firefox 和 IE 中测试了自动对焦,使用方法:
它在 2 文档类型的 Firefox 中运行良好。 HTML5 和 XHTML1.0
我还没有在这种情况下尝试过,但是将 HTML5 shim 放入标头中似乎可以使 IE 表现得更好。
autofocus seems to work fine, however it is not supported in IE. So you're likely stuck with javascript for now.
I tested autofocus in firefox and IE using:
it work well in firefox with 2 doctypes. HTML5 and XHTML1.0
I haven't tried it in this context but putting the HTML5 shim in your header seems to make IE behave much better.
如果您使用过 dojo
getFocusOnLoad()
可能有助于在页面加载时设置焦点。请访问以下链接:
If you have used dojo
getFocusOnLoad()
might help to set the focus when the a page loads..Please follow these links: