Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在 ASP.Net 中的表单上使用 defaultfocus 属性,因此我将此属性设置为文本框。这在 IE 上按预期工作,但在 Safari 4 beta 中,文本框的内容也被选中。如何在 Safari 上按预期工作?
我也尝试了一些 jquery 调用,问题也存在:
$("input:visible:enabled:first").focus();
在 Safari 中,它看起来像是调用 select() 而不是焦点。有没有人可以解决这个问题?
似乎您必须设置文本框的值才能在字段中而不是选择中获得焦点:
var firstInput = $("input:text:first"); firstInput.focus(); firstInput.val(firstInput.val());
我相信 .net 的东西与 Safari/其他浏览器没有的特定于 IE 的 defaultfocus 属性挂钩。
我认为这会自动聚焦特定领域?