2011-07-01 114 views
4

請幫助我的人,,,,如何在彈出窗口中設置提交按鈕的默認焦點

我寫了一些代碼,使用下面的代碼來獲得彈出窗口。

<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函數中寫入代碼以獲得彈出窗口,所以我需要在上面的代碼中提到的提交按鈕上設置默認焦點。

回答

9

您可以將焦點設置與使用JavaScript或jQuery的的提交按鈕:

的JavaScript:

document.getElementById('emailConfm').focus(); 

jQuery

$('#emailConfm').focus(); 
4

您可以使用下面的設置重點放入按鈕

document.getElementById('emailConfm').focus(); 

但這可能行不通,要解決這個問題我做了這樣的事情

setTimeout(function() { document.getElementById('emailConfm').focus(); },100); 
相關問題