我正在开发一种表单,可以将新的招聘数据传输到我们的JSON招聘中。 我刚开始,但是Node.js还是一个新手,我正在测试。 您能否让我知道如何防止出现此错误。

错误:TypeError:表单未定义http:// localhost:63342 / VAP_FORM / index.html:32:11

浏览器:firefox

 /** * Retrieves input data from a form and returns it as a JSON object. * @param {HTMLFormControlsCollection} elements the form elements * @return {Object} form data as an object literal */ const formToJSON = elements => [].reduce.call(elements, (data, element) => { data[element.name] = element.value; return data; }, {}); /** * A handler function to prevent default submission and run our custom script. * @param {Event} event the submit event triggered by the user * @return {void} */ const handleFormSubmit = event => { event.preventDefault(); const data = formToJSON(form.elements); const dataContainer = document.getElementsByClassName('results__display')[0]; dataContainer.textContent = JSON.stringify(data, null, " "); console.log(dataContainer); }; /* We find the form element using its class name, then attach the * `handleFormSubmit()` function to the * `submit` event. */ const form = document.getElementsByClassName('contact-form')[0]; form.addEventListener('submit', handleFormSubmit); 
 .valid{ border:1px solid blue; } .invalid{ border:1px solid red; } .column { float: left; padding: 10px; height: 300px; /* Should be removed. Only for demonstration */ } .left{ width: 10%; } .right { width: 30%; } .middle { width: 60%; min-width: 300px; height: 100%; } .row:after { content: ""; display: table; clear: both; } #vapheading { color: black; font-family: Avenir; } #form{ color: white; background-color: navy; padding: 16px; border-radius: 25px; } @media only screen and (max-width: 1026px) { #left,#right { display: none; } } input { border: 4px solid whitesmoke; border-radius: 25px; background-color: whitesmoke; } select { border: 4px solid whitesmoke; border-radius: 25px; background-color: whitesmoke; } body{ background-color: lightgrey; color: white; } 
 <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <link rel="stylesheet" type="text/css" href="vap_css.css"/> <script src="vap_script.js"></script> <script> function validateForm() { var x = document.forms["myForm"]["ssn1"].value; var y = document.forms["myForm"]["ssn2"].value; if (x !== y ){ alert("Social Security number does not match"); return false; } } </script> </head> <body> <div class="row"> <div class="column left" id="left"></div> <div class="column middle" id="middle"> <h2 id = "vapheading">Please fill out the Following Form</h2> <div id = "form"> <form class="contact-form__label" name="myForm" onsubmit="return validateForm()"> <table id = "table"> <tr> <td>First Name:* <br/><input type="text" name="firstname" id="fname" required/></td> <td>Middle Name: <br/><input type="text" name="middlename" id="mname" /></td> <td>Last Name:* <br/><input type="text" name="lastname" id="lname" required/></td> </tr> <tr> <td>Suffix: <br/><input type="text" name="suffix" id="suffix" /></td> </tr> </table> <table> <tr> <td>SSN:* <br/><input class="required-input" id="ssn1" maxlength="9" type="password" name="ssn1" required/></td> <td>Verify SSN:* <br/><input class="required-input" id="ssn2" maxlength="9" type="password" name="ssn2" required/></td> <td>Date of Birth:* <br/><input type="date" name="birthday" id="bday" required/></td> </tr> </table> <table> <tr> <td>Place of Birth - City:* <br/><input type="text" name="city" id="city" required/></td> <td>Place of Birth - State: <br/><input type="text" name="state" id="state" ></td> <td>Place of Birth - Country:* <br/><select name="country" id="country" required> <option value="">Choose Here</option> <option value="Afghanistan">Afghanistan</option><option value="Albania">Albania</option><option value="Algeria">Algeria</option><option value="Andorra">Andorra</option> <option value="Angola">Angola</option><option value="Antigua & Deps">Antigua & Deps</option><option value="Argentina">Argentina</option> <option value="Armenia">Armenia</option><option value="Australia">Australia</option><option value="Austria">Austria</option> <option value="Azerbaijan">Azerbaijan</option><option value="Bahamas">Bahamas</option><option value="Bahrain">Bahrain</option> <option value="Bangladesh">Bangladesh</option><option value="Barbados">Barbados</option><option value="Belarus">Belarus</option> <option value="Belgium">Belgium</option><option value="Belize">Belize</option><option value="Benin">Benin</option> <option value="Bhutan">Bhutan</option><option value="Bolivia">Bolivia</option><option value="Bosnia Herzegovina">Bosnia Herzegovina</option> <option value="Botswana">Botswana</option><option value="Brazil">Brazil</option><option value="Brunei">Brunei</option> <option value="Bulgaria">Bulgaria</option><option value="Burkina">Burkina</option><option value="Burundi">Burundi</option> <option value="Cambodia">Cambodia</option><option value="Cameroon">Cameroon</option><option value="Canada">Canada</option> <option value="Cape Verde">Cape Verde</option><option value="Central African Rep">Central African Rep</option><option value="Chad">Chad</option> <option value="Chile">Chile</option><option value="China">China</option><option value="Colombia">Colombia</option> <option value="Comoros">Comoros</option><option value="Congo">Congo</option><option value="Congo {Democratic Rep}">Congo {Democratic Rep}</option> <option value="Costa Rica">Costa Rica</option><option value="Croatia">Croatia</option><option value="Cuba">Cuba</option> <option value="Cyprus">Cyprus</option><option value="Czech Republic">Czech Republic</option><option value="Denmark">Denmark</option> <option value="Djibouti">Djibouti</option><option value="Dominica">Dominica</option><option value="Dominican Republic">Dominican Republic</option> <option value="East Timor">East Timor</option><option value="Ecuador">Ecuador</option><option value="Egypt">Egypt</option> <option value="El Salvador">El Salvador</option><option value="Equatorial Guinea">Equatorial Guinea</option><option value="Eritrea">Eritrea</option> <option value="Estonia">Estonia</option><option value="Ethiopia">Ethiopia</option><option value="Fiji">Fiji</option> <option value="Finland">Finland</option><option value="France">France</option><option value="Gabon">Gabon</option> <option value="Gambia">Gambia</option><option value="Georgia">Georgia</option><option value="Germany">Germany</option> <option value="Ghana">Ghana</option><option value="Greece">Greece</option><option value="Grenada">Grenada</option> <option value="Guatemala">Guatemala</option><option value="Guinea">Guinea</option><option value="Guinea-Bissau">Guinea-Bissau</option> <option value="Guyana">Guyana</option><option value="Haiti">Haiti</option><option value="Honduras">Honduras</option> <option value="Hungary">Hungary</option><option value="Iceland">Iceland</option><option value="India">India</option> <option value="Indonesia">Indonesia</option><option value="Iran">Iran</option><option value="Iraq">Iraq</option> <option value="Ireland {Republic}">Ireland {Republic}</option><option value="Israel">Israel</option><option value="Italy">Italy</option> <option value="Ivory Coast">Ivory Coast</option><option value="Jamaica">Jamaica</option><option value="Japan">Japan</option> <option value="Jordan">Jordan</option><option value="Kazakhstan">Kazakhstan</option><option value="Kenya">Kenya</option> <option value="Kiribati">Kiribati</option><option value="Korea North">Korea North</option><option value="Korea South">Korea South</option> <option value="Kosovo">Kosovo</option><option value="Kuwait">Kuwait</option><option value="Kyrgyzstan">Kyrgyzstan</option> <option value="Laos">Laos</option><option value="Latvia">Latvia</option><option value="Lebanon">Lebanon</option> <option value="Lesotho">Lesotho</option><option value="Liberia">Liberia</option><option value="Libya">Libya</option> <option value="Liechtenstein">Liechtenstein</option><option value="Lithuania">Lithuania</option><option value="Luxembourg">Luxembourg</option> <option value="Macedonia">Macedonia</option><option value="Madagascar">Madagascar</option><option value="Malawi">Malawi</option> <option value="Malaysia">Malaysia</option><option value="Maldives">Maldives</option><option value="Mali">Mali</option> <option value="Malta">Malta</option><option value="Marshall Islands">Marshall Islands</option><option value="Mauritania">Mauritania</option> <option value="Mauritius">Mauritius</option><option value="Mexico">Mexico</option><option value="Micronesia">Micronesia</option> <option value="Moldova">Moldova</option><option value="Monaco">Monaco</option><option value="Mongolia">Mongolia</option> <option value="Montenegro">Montenegro</option><option value="Morocco">Morocco</option><option value="Mozambique">Mozambique</option> <option value="Myanmar, {Burma}">Myanmar, {Burma}</option><option value="Namibia">Namibia</option><option value="Nauru">Nauru</option> <option value="Nepal">Nepal</option><option value="Netherlands">Netherlands</option><option value="New Zealand">New Zealand</option> <option value="Nicaragua">Nicaragua</option><option value="Niger">Niger</option><option value="Nigeria">Nigeria</option> <option value="Norway">Norway</option><option value="Oman">Oman</option><option value="Pakistan">Pakistan</option> <option value="Palau">Palau</option><option value="Panama">Panama</option><option value="Papua New Guinea">Papua New Guinea</option> <option value="Paraguay">Paraguay</option><option value="Peru">Peru</option><option value="Philippines">Philippines</option> <option value="Poland">Poland</option><option value="Portugal">Portugal</option><option value="Qatar">Qatar</option> <option value="Romania">Romania</option><option value="Russian Federation">Russian Federation</option><option value="Rwanda">Rwanda</option> <option value="St Kitts & Nevis">St Kitts & Nevis</option><option value="St Lucia">St Lucia</option><option value="Saint Vincent & the Grenadines">Saint Vincent & the Grenadines</option> <option value="Samoa">Samoa</option><option value="San Marino">San Marino</option><option value="Sao Tome & Principe">Sao Tome & Principe</option> <option value="Saudi Arabia">Saudi Arabia</option><option value="Senegal">Senegal</option><option value="Serbia">Serbia</option> <option value="Seychelles">Seychelles</option><option value="Sierra Leone">Sierra Leone</option><option value="Singapore">Singapore</option> <option value="Slovakia">Slovakia</option><option value="Slovenia">Slovenia</option><option value="Solomon Islands">Solomon Islands</option> <option value="Somalia">Somalia</option><option value="South Africa">South Africa</option><option value="South Sudan">South Sudan</option> <option value="Spain">Spain</option><option value="Sri Lanka">Sri Lanka</option><option value="Sudan">Sudan</option> <option value="Suriname">Suriname</option><option value="Swaziland">Swaziland</option><option value="Sweden">Sweden</option> <option value="Switzerland">Switzerland</option><option value="Syria">Syria</option><option value="Taiwan">Taiwan</option> <option value="Tajikistan">Tajikistan</option><option value="Tanzania">Tanzania</option><option value="Thailand">Thailand</option> <option value="Togo">Togo</option><option value="Tonga">Tonga</option><option value="Trinidad & Tobago">Trinidad & Tobago</option> <option value="Tunisia">Tunisia</option><option value="Turkey">Turkey</option><option value="Turkmenistan">Turkmenistan</option> <option value="Tuvalu">Tuvalu</option><option value="Uganda">Uganda</option><option value="Ukraine">Ukraine</option> <option value="United Arab Emirates">United Arab Emirates</option><option value="United Kingdom">United Kingdom</option><option value="United States">United States</option> <option value="Uruguay">Uruguay</option><option value="Uzbekistan">Uzbekistan</option><option value="Vanuatu">Vanuatu</option> <option value="Vatican City">Vatican City</option><option value="Venezuela">Venezuela</option><option value="Vietnam">Vietnam</option> <option value="Yemen">Yemen</option><option value="Zambia">Zambia</option><option value="Zimbabwe">Zimbabwe</option> </select></td> </tr> <tr> <td>Citizenship:* <br/><select name="citizenship" id="citixen" default required> <option value="">Choose Here</option> <option value="USCitizen">US Citizen</option> <option value="greencard">Green Card</option> <option value="H1B">H1B</option> <option value="EAD">EAD</option> <option value="Other">Other</option> </select></td> </tr> </table> <br/><br/><button type="submit">Submit</button> </form> </div> </div> <div class="column right" id="right"></div> </div> </body> </html> 

#1楼 票数:0 已采纳

您的班级名称选择器不起作用,请使用完整的班级名称contact-form__label ,也可以使用getElementsByName代替。 但是,也要在加载DOM之前导入脚本,因此您将需要在正文底部移动脚本导入。

如果出于某种原因您不想移动脚本,则可以将表单选择包装在事件中,该事件将在页面竞争准备就绪时执行,如下所示:

document.addEventListener("DOMContentLoaded", function(event) { 
  let form = document.getElementsByClassName('contact-form__label')[0];
  form.addEventListener('submit', handleFormSubmit);
});

 /** * Retrieves input data from a form and returns it as a JSON object. * @param {HTMLFormControlsCollection} elements the form elements * @return {Object} form data as an object literal */ const formToJSON = elements => [].reduce.call(elements, (data, element) => { data[element.name] = element.value; return data; }, {}); /** * A handler function to prevent default submission and run our custom script. * @param {Event} event the submit event triggered by the user * @return {void} */ const handleFormSubmit = event => { event.preventDefault(); const data = formToJSON(form.elements); const dataContainer = document.getElementsByClassName('results__display')[0]; dataContainer.textContent = JSON.stringify(data, null, " "); console.log(dataContainer); }; /* We find the form element using its class name, then attach the * `handleFormSubmit()` function to the * `submit` event. */ let form = document.getElementsByClassName('contact-form__label')[0]; form.addEventListener('submit', handleFormSubmit); 
 .valid{ border:1px solid blue; } .invalid{ border:1px solid red; } .column { float: left; padding: 10px; height: 300px; /* Should be removed. Only for demonstration */ } .left{ width: 10%; } .right { width: 30%; } .middle { width: 60%; min-width: 300px; height: 100%; } .row:after { content: ""; display: table; clear: both; } #vapheading { color: black; font-family: Avenir; } #form{ color: white; background-color: navy; padding: 16px; border-radius: 25px; } @media only screen and (max-width: 1026px) { #left,#right { display: none; } } input { border: 4px solid whitesmoke; border-radius: 25px; background-color: whitesmoke; } select { border: 4px solid whitesmoke; border-radius: 25px; background-color: whitesmoke; } body{ background-color: lightgrey; color: white; } 
 <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <link rel="stylesheet" type="text/css" href="vap_css.css"/> <script> function validateForm() { var x = document.forms["myForm"]["ssn1"].value; var y = document.forms["myForm"]["ssn2"].value; if (x !== y ){ alert("Social Security number does not match"); return false; } } </script> </head> <body> <div class="row"> <div class="column left" id="left"></div> <div class="column middle" id="middle"> <h2 id = "vapheading">Please fill out the Following Form</h2> <div id = "form"> <form class="contact-form__label" name="myForm" onsubmit="return validateForm()"> <table id = "table"> <tr> <td>First Name:* <br/><input type="text" name="firstname" id="fname" required/></td> <td>Middle Name: <br/><input type="text" name="middlename" id="mname" /></td> <td>Last Name:* <br/><input type="text" name="lastname" id="lname" required/></td> </tr> <tr> <td>Suffix: <br/><input type="text" name="suffix" id="suffix" /></td> </tr> </table> <table> <tr> <td>SSN:* <br/><input class="required-input" id="ssn1" maxlength="9" type="password" name="ssn1" required/></td> <td>Verify SSN:* <br/><input class="required-input" id="ssn2" maxlength="9" type="password" name="ssn2" required/></td> <td>Date of Birth:* <br/><input type="date" name="birthday" id="bday" required/></td> </tr> </table> <table> <tr> <td>Place of Birth - City:* <br/><input type="text" name="city" id="city" required/></td> <td>Place of Birth - State: <br/><input type="text" name="state" id="state" ></td> <td>Place of Birth - Country:* <br/><select name="country" id="country" required> <option value="">Choose Here</option> <option value="Afghanistan">Afghanistan</option><option value="Albania">Albania</option><option value="Algeria">Algeria</option><option value="Andorra">Andorra</option> <option value="Angola">Angola</option><option value="Antigua & Deps">Antigua & Deps</option><option value="Argentina">Argentina</option> <option value="Armenia">Armenia</option><option value="Australia">Australia</option><option value="Austria">Austria</option> <option value="Azerbaijan">Azerbaijan</option><option value="Bahamas">Bahamas</option><option value="Bahrain">Bahrain</option> <option value="Bangladesh">Bangladesh</option><option value="Barbados">Barbados</option><option value="Belarus">Belarus</option> <option value="Belgium">Belgium</option><option value="Belize">Belize</option><option value="Benin">Benin</option> <option value="Bhutan">Bhutan</option><option value="Bolivia">Bolivia</option><option value="Bosnia Herzegovina">Bosnia Herzegovina</option> <option value="Botswana">Botswana</option><option value="Brazil">Brazil</option><option value="Brunei">Brunei</option> <option value="Bulgaria">Bulgaria</option><option value="Burkina">Burkina</option><option value="Burundi">Burundi</option> <option value="Cambodia">Cambodia</option><option value="Cameroon">Cameroon</option><option value="Canada">Canada</option> <option value="Cape Verde">Cape Verde</option><option value="Central African Rep">Central African Rep</option><option value="Chad">Chad</option> <option value="Chile">Chile</option><option value="China">China</option><option value="Colombia">Colombia</option> <option value="Comoros">Comoros</option><option value="Congo">Congo</option><option value="Congo {Democratic Rep}">Congo {Democratic Rep}</option> <option value="Costa Rica">Costa Rica</option><option value="Croatia">Croatia</option><option value="Cuba">Cuba</option> <option value="Cyprus">Cyprus</option><option value="Czech Republic">Czech Republic</option><option value="Denmark">Denmark</option> <option value="Djibouti">Djibouti</option><option value="Dominica">Dominica</option><option value="Dominican Republic">Dominican Republic</option> <option value="East Timor">East Timor</option><option value="Ecuador">Ecuador</option><option value="Egypt">Egypt</option> <option value="El Salvador">El Salvador</option><option value="Equatorial Guinea">Equatorial Guinea</option><option value="Eritrea">Eritrea</option> <option value="Estonia">Estonia</option><option value="Ethiopia">Ethiopia</option><option value="Fiji">Fiji</option> <option value="Finland">Finland</option><option value="France">France</option><option value="Gabon">Gabon</option> <option value="Gambia">Gambia</option><option value="Georgia">Georgia</option><option value="Germany">Germany</option> <option value="Ghana">Ghana</option><option value="Greece">Greece</option><option value="Grenada">Grenada</option> <option value="Guatemala">Guatemala</option><option value="Guinea">Guinea</option><option value="Guinea-Bissau">Guinea-Bissau</option> <option value="Guyana">Guyana</option><option value="Haiti">Haiti</option><option value="Honduras">Honduras</option> <option value="Hungary">Hungary</option><option value="Iceland">Iceland</option><option value="India">India</option> <option value="Indonesia">Indonesia</option><option value="Iran">Iran</option><option value="Iraq">Iraq</option> <option value="Ireland {Republic}">Ireland {Republic}</option><option value="Israel">Israel</option><option value="Italy">Italy</option> <option value="Ivory Coast">Ivory Coast</option><option value="Jamaica">Jamaica</option><option value="Japan">Japan</option> <option value="Jordan">Jordan</option><option value="Kazakhstan">Kazakhstan</option><option value="Kenya">Kenya</option> <option value="Kiribati">Kiribati</option><option value="Korea North">Korea North</option><option value="Korea South">Korea South</option> <option value="Kosovo">Kosovo</option><option value="Kuwait">Kuwait</option><option value="Kyrgyzstan">Kyrgyzstan</option> <option value="Laos">Laos</option><option value="Latvia">Latvia</option><option value="Lebanon">Lebanon</option> <option value="Lesotho">Lesotho</option><option value="Liberia">Liberia</option><option value="Libya">Libya</option> <option value="Liechtenstein">Liechtenstein</option><option value="Lithuania">Lithuania</option><option value="Luxembourg">Luxembourg</option> <option value="Macedonia">Macedonia</option><option value="Madagascar">Madagascar</option><option value="Malawi">Malawi</option> <option value="Malaysia">Malaysia</option><option value="Maldives">Maldives</option><option value="Mali">Mali</option> <option value="Malta">Malta</option><option value="Marshall Islands">Marshall Islands</option><option value="Mauritania">Mauritania</option> <option value="Mauritius">Mauritius</option><option value="Mexico">Mexico</option><option value="Micronesia">Micronesia</option> <option value="Moldova">Moldova</option><option value="Monaco">Monaco</option><option value="Mongolia">Mongolia</option> <option value="Montenegro">Montenegro</option><option value="Morocco">Morocco</option><option value="Mozambique">Mozambique</option> <option value="Myanmar, {Burma}">Myanmar, {Burma}</option><option value="Namibia">Namibia</option><option value="Nauru">Nauru</option> <option value="Nepal">Nepal</option><option value="Netherlands">Netherlands</option><option value="New Zealand">New Zealand</option> <option value="Nicaragua">Nicaragua</option><option value="Niger">Niger</option><option value="Nigeria">Nigeria</option> <option value="Norway">Norway</option><option value="Oman">Oman</option><option value="Pakistan">Pakistan</option> <option value="Palau">Palau</option><option value="Panama">Panama</option><option value="Papua New Guinea">Papua New Guinea</option> <option value="Paraguay">Paraguay</option><option value="Peru">Peru</option><option value="Philippines">Philippines</option> <option value="Poland">Poland</option><option value="Portugal">Portugal</option><option value="Qatar">Qatar</option> <option value="Romania">Romania</option><option value="Russian Federation">Russian Federation</option><option value="Rwanda">Rwanda</option> <option value="St Kitts & Nevis">St Kitts & Nevis</option><option value="St Lucia">St Lucia</option><option value="Saint Vincent & the Grenadines">Saint Vincent & the Grenadines</option> <option value="Samoa">Samoa</option><option value="San Marino">San Marino</option><option value="Sao Tome & Principe">Sao Tome & Principe</option> <option value="Saudi Arabia">Saudi Arabia</option><option value="Senegal">Senegal</option><option value="Serbia">Serbia</option> <option value="Seychelles">Seychelles</option><option value="Sierra Leone">Sierra Leone</option><option value="Singapore">Singapore</option> <option value="Slovakia">Slovakia</option><option value="Slovenia">Slovenia</option><option value="Solomon Islands">Solomon Islands</option> <option value="Somalia">Somalia</option><option value="South Africa">South Africa</option><option value="South Sudan">South Sudan</option> <option value="Spain">Spain</option><option value="Sri Lanka">Sri Lanka</option><option value="Sudan">Sudan</option> <option value="Suriname">Suriname</option><option value="Swaziland">Swaziland</option><option value="Sweden">Sweden</option> <option value="Switzerland">Switzerland</option><option value="Syria">Syria</option><option value="Taiwan">Taiwan</option> <option value="Tajikistan">Tajikistan</option><option value="Tanzania">Tanzania</option><option value="Thailand">Thailand</option> <option value="Togo">Togo</option><option value="Tonga">Tonga</option><option value="Trinidad & Tobago">Trinidad & Tobago</option> <option value="Tunisia">Tunisia</option><option value="Turkey">Turkey</option><option value="Turkmenistan">Turkmenistan</option> <option value="Tuvalu">Tuvalu</option><option value="Uganda">Uganda</option><option value="Ukraine">Ukraine</option> <option value="United Arab Emirates">United Arab Emirates</option><option value="United Kingdom">United Kingdom</option><option value="United States">United States</option> <option value="Uruguay">Uruguay</option><option value="Uzbekistan">Uzbekistan</option><option value="Vanuatu">Vanuatu</option> <option value="Vatican City">Vatican City</option><option value="Venezuela">Venezuela</option><option value="Vietnam">Vietnam</option> <option value="Yemen">Yemen</option><option value="Zambia">Zambia</option><option value="Zimbabwe">Zimbabwe</option> </select></td> </tr> <tr> <td>Citizenship:* <br/><select name="citizenship" id="citixen" default required> <option value="">Choose Here</option> <option value="USCitizen">US Citizen</option> <option value="greencard">Green Card</option> <option value="H1B">H1B</option> <option value="EAD">EAD</option> <option value="Other">Other</option> </select></td> </tr> </table> <br/><br/><button type="submit">Submit</button> </form> </div> </div> <div class="column right" id="right"></div> </div> <script src="vap_script.js"></script> </body> </html> 

#2楼 票数:0

您应该在JavaScript代码的开头添加以下行:

var form = document.forms[0];

现在,您可以访问form变量。

  ask by Geoffrey Jennings translate from so

未解决问题?本站智能推荐:

1回复

Firefox不会在第一次/页面加载时触发“播放”或“播放”事件

当音频播放器在页面加载时播放音频文件时,我似乎无法让 Firefox v20.0 首次触发“播放”或“播放”事件。 如果我单击暂停,然后单击播放,“播放”和“播放”事件都会触发,但不会在初始页面加载时触发。 我已经尝试使用下面的 vanilla JS 绑定到“播放”/“播放”事件,甚至尝试使用 jQ
4回复

需要未定义javascript

****** 编辑 ******* 我现在确实意识到了这个错误,当我测试我的需求时,我正在我的终端中运行我的脚本。 ****** 老 **** 答案可能都在页面上准备好了,但我找不到它,我看到的一般答案是我不能在客户端使用“require”。 问题是我试图在我的学校笔记本电脑上完美运行的脚本。
1回复

Firefox后退按钮只能在第一次使用,而不能第二次使用

我有一个网站,您可以在其中搜索有关日期和更多内容的信息。 当我发布表单时,我进入结果页面,当我按下“后退”按钮时,我返回到搜索页面,并将重新填充值。 这适用于IE和FF。 但是,无论执行什么操作,当我第二次搜索并再次返回时 ,这些值在Firefox中都会丢失,而IE和其他浏览器仍会记住所
2回复

Firefox中未定义的表单

我正在尝试获取element选项的值: 这是函数add_decoration(obj): 现在,这既适用于Chrome和IE8,又不适用于Firefox 3.5。 火狐错误控制台说: 不使用大量开关怎么办才能保持代码干净? 提前致谢
2回复

Firefox认为未定义表单,但IE和Chrome可以

我正在尝试获取下拉菜单选择的值。 这是我的XHTML: 这是我的JavaScript: 它在IE和Chrome中完美运行。 但是,当我在Firefox中按下“提交”按钮时,什么也没有发生。 Firebug告诉我myForm未定义。 是什么赋予了? 有解决方法吗?
2回复

反应:location.state在页面加载后第一次导航时未定义

我有一个 React 组件,它显示一个链接: 魔术.tsx: 我将此Magic组件作为 Prop 传递给另一个组件,在那里我正在迭代它,并带有动态message状态父.tsx 这是正确呈现链接。 但是当我点击链接并调试HOGWARTS页面时,location.state 是未定义的。 如果回到上一页
2回复

Vue.prototype在页面第一次加载时未定义

所以,我试图在我的main.js文件中使用 axios 发出请求。 如图所示,我正在使用 vue-router 在加载每个组件之前发出此请求。 但是,当我的网页第一次加载时,我无法让它工作。 我的意思是,axios 请求是在组件加载后完成的。 然后,这将失败: 它在控制台日志中显示了这个错误: 我试
2回复

FirefoxReferenceError:未定义jQuery

我在我的网站上使用wordpress ,它在所有浏览器上的运行文件都需要FireFox 。 在firefox我的站点加载一半没有样式和js文件,只有 html 版本在控制台中出现这些错误。 但我在脑海中包含了jQuery : 但它仍然无法在 Firefox 中工作。 知道为什么它在 Firefox