灯箱专注于输入,仅在刷新后有效
我有一个登录框,当您单击登录按钮时会弹出,并且该灯箱将加载一个登录表单。
我尝试过设置 onLoad="document.loginForm.login.focus()" 尝试在页面加载时将焦点设置在登录框上。
然而,这似乎只有在刷新灯箱中的登录表单后才有效,而不是其背后的父文档。
我尝试向该函数添加超时选项,因为我认为这可能是一个计时问题,但这似乎不起作用。
有谁知道为什么它在刷新后有效,但在第一次加载时不起作用?
谢谢 编辑
I have a login box that pops up when you click on the login button, and that lightbox will have a login form loaded into it.
I have tried setting
onLoad="document.loginForm.login.focus()" to try and set the focus on the login box when the page loads.
However, this seems to only work, after you refresh the login form in the lightbox, not the parent documents behind it.
I have tried adding a timeout option to the function as I thought it may be a timing issue, but this does not seem to have worked.
Does anyone have any ideas why it works after a refresh, but not on first load?
Thanks
Eds
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为这应该对您有所帮助:
如果您的页面中有多个 iframe,则为您的目标 iframe 提供一个 id 并使用
$("#myIframeId")
而不是$(" iframe”)
I think this should help you:
If you have more than one iframe in your page, then give an id to your target iframe and use
$("#myIframeId")
instead of$("iframe")
尝试在按钮单击事件上调用
document.loginForm.login.focus()
。Try calling
document.loginForm.login.focus()
on button click event.