首页 > 解决方案 > 输入密码后在文本框中运行事件

问题描述

我正在尝试在下面的 HTML 代码的密码字段中输入密码:

<input name="customerPassword" type="password" class="customer-password form-control ng-dirty ng-valid-required filled ng-valid ng-valid-minlength" ng-class="{
  'input-error': submitted &amp;&amp; securityForm.customerPassword.$invalid,
  'filled': securityForm.customerPassword.$viewValue.length>0}" ng-minlength="7" maxlength="20" ng-model="customer.password" ng-keydown="checkEnterKey(event)" required="" autocomplete="new-password" aria-autocomplete="list">
<b class="into-input">Password</b>
<div class="ct-icon ng-hide" ng-show="securityForm.$invalid">
            <div class="ct-tooltip">
                <i class="fa fa-info-circle fa-lg info"></i>
                <div class="tooltip">
                    <div class=""><p>This is the password you created when you registered for Internet Banking.&nbsp;</p></div>
                </div>
            </div>
        </div>
<met-tooltip category="login" key="input-password" ng-show="securityForm.$valid" icon="check" class="valid-number met-tooltip-bg-green ng-isolate-scope"><span>    <!-- ngIf: !tooltip.inline --><a ng-if="!tooltip.inline" href="javascript:void(0)" tabindex="-1" tooltip-trigger="" tooltip-placement="" tooltip-html-unsafe="<p><span style=&quot;line-height:20.8px&quot;>Password entered.</span></p>
" tooltip-popup-delay="100" class="ng-scope">        <i data-ng-click="goTo()" class="fa fa-check-circle"></i>    </a><!-- end ngIf: !tooltip.inline -->    <!-- ngIf: tooltip.inline --></span></met-tooltip>
<a ng-if="!tooltip.inline" href="javascript:void(0)" tabindex="-1" tooltip-trigger="" tooltip-placement="" tooltip-html-unsafe="<p><span style=&quot;line-height:20.8px&quot;>Password entered.</span></p>
" tooltip-popup-delay="100" class="ng-scope">        <i data-ng-click="goTo()" class="fa fa-check-circle"></i>    </a>

请参阅下面我的 VBA 代码片段:

  Dim event_onChange As Object
  Set event_onChange = ie.document.createEvent("HTMLEvents")
    event_onChange.initEvent "keydown", True, False
   .document.querySelector(".customer-password").dispatchEvent event_onChange

当我手动输入密码时会出现一个小圆圈,但在我运行 VBA 代码后它不会出现。VBA 怎么可能做到这一点?

标签: htmlexcelvba

解决方案


推荐阅读