我试图在页面上找到一个元素并从safari控制台设置它的值,我能够得到完全相同的东西在chrome上但不是safari。我使用的网页是此网站https://kith.com上的Shopify付款页面。要到达它,你必须添加和项目并假装结帐
页面应该如下所示
我正在使用的javascript是
document.getElementById('number').value = '000011112222333';
Safari返回TypeError:null不是对象消息。
这是表单代码
<form>
<label for="number" class="visually-hidden" aria-hidden="true">Credit Card Number</label>
<input autocomplete="cc-number" id="number" name="number" type="tel" aria-describedby="error-for-number" data-current-field="number" class="input-placeholder-color--lvl-34" placeholder="Card number" style="color: rgb(51, 51, 51); font-family: Lato; padding: 0.94em 0.8em; transition: padding 0.2s ease-out;">
<span id="error-for-number" class="input-error-message visually-hidden"></span>
<label for="name" class="visually-hidden" aria-hidden="true">Name on card</label>
<input autocomplete="cc-name" id="name" name="name" type="text" class="visually-hidden" aria-hidden="true" data-honeypot-field="" tabindex="-1">
<label for="expiry_month" class="visually-hidden" aria-hidden="true">Expiry month</label>
<input autocomplete="cc-exp-month" id="expiry_month" name="expiry_month" type="tel" class="visually-hidden" aria-hidden="true" data-honeypot-field="" tabindex="-1">
<label for="expiry_year" class="visually-hidden" aria-hidden="true">Expiry year</label>
<input autocomplete="cc-exp-year" id="expiry_year" name="expiry_year" type="tel" class="visually-hidden" aria-hidden="true" data-honeypot-field="" tabindex="-1">
<label for="expiry" class="visually-hidden" aria-hidden="true">MM / YY</label>
<input autocomplete="cc-exp" id="expiry" name="expiry" type="tel" class="visually-hidden" aria-hidden="true" data-honeypot-field="" tabindex="-1">
<label for="verification_value" class="visually-hidden" aria-hidden="true">CVV</label>
<input autocomplete="off" id="verification_value" name="verification_value" type="tel" class="visually-hidden" aria-hidden="true" data-honeypot-field="" tabindex="-1">
<label for="issue_date" class="visually-hidden" aria-hidden="true">Issue date (MM / YY)</label>
<input autocomplete="off" id="issue_date" name="issue_date" type="tel" class="visually-hidden" aria-hidden="true" data-honeypot-field="" tabindex="-1">
<label for="issue_number" class="visually-hidden" aria-hidden="true">Issue number</label>
<input autocomplete="off" id="issue_number" name="issue_number" type="tel" class="visually-hidden" aria-hidden="true" data-honeypot-field="" tabindex="-1">
<button type="submit" class="visually-hidden" tabindex="-1">
<script src="https://checkout.shopifycs.com/build/boot-2a790b3233.js"></script>
答案 0 :(得分:0)
您可以查看&#39;号码的顺序。元素和脚本。必须在通过脚本访问之前定义该元素。