请帮帮我,……
我使用下面的代码编写了一些代码来获取弹出窗口。
<div id="EMAIL_CONFIRMATION_PENDING" class="popupContact" style="z-index:10003;">
<div class="popup_textarea">
<h3><h:outputLabel value="#{labelMsgs.emailPendingLabel}"/></h3>
<div class="VerifyEmailText">
<h:outputLabel value="#{labelMsgs.clickToSendEmail}"/>
<span class="FontItalic"><h:outputLabel value="#{headerBean.emailAddress}."/></span>
<br /><br />
</div>
<div class="SuspendedBoxMsg">
<h:outputLabel value="#{labelMsgs.accountSuspend}"/><br />
<h3><h:outputLabel value="#{sessionScope.DASHBOARD_EMAIL_EXP_TIME}"/></h3>
<h:outputLabel value="#{labelMsgs.unlessYouVerify}"/>
<br />
</div>
<div>
<span class="FontWeight">
<h:outputLabel value="#{labelMsgs.spamMailFolder}"/>
</span>
<a4j:commandLink id="resendLink" styleClass="violet_color_link" value="#{labelMsgs.regSuccSendMail}" onclick="javascript:resendLink(); this.onclick=null;" action="#{headerBean.resendEmail}" />
</div>
<div class="OkButton">
<div class="button_input">
<a4j:commandButton id="emailConfm" styleClass="image_button" value="#{labelMsgs.okButton}" action="#{accntDashboardBean.popupRefresh}"
reRender="frmAccountDashboardMenu:POPUP_PANEL" oncomplete="disablePopup1('EMAIL_CONFIRMATION_PENDING', 'backgroundPopup');popupCall('#{sessionScope.toShowPopupOf}');"/>
</div>
</div>
</div>
</div>
在这里,我使用div的id来填充弹出窗口,就像这样,我已经写了一些具有不同id的其他弹出窗口代码。为此,我在window.onload函数中编写代码以获得弹出窗口,因此,我需要在上面代码中提到的提交按钮上设置默认焦点。
发布于 2011-07-01 14:47:14
您可以使用JavaScript或jQuery将焦点设置到submit按钮:
JavaScript:
document.getElementById('emailConfm').focus();
jQuery
$('#emailConfm').focus();
发布于 2014-04-06 15:21:18
您可以使用以下命令将焦点设置到按钮中
document.getElementById('emailConfm').focus();
但这可能不起作用,为了解决这个问题,我做了如下操作
setTimeout(function() { document.getElementById('emailConfm').focus(); },100);
发布于 2018-08-02 13:13:38
您可以在div中使用HTML form标记来设置提交按钮的焦点。在表单标签中使用您的输入标签,因此每当您输入用户名或密码时,提交按钮总是集中在按下Enter按钮。
<form>
<input type="text"/>
<input type="password"/>
<input type="submit"/>
</form>
https://stackoverflow.com/questions/6544438
复制相似问题