简体   繁体   中英

My HTML just loads forever when I press the button

When I press the button there is supposed to be a timeout feature (with a loading screen) for 2 seconds, then it sends you to the page. For some unknown reason it is not working and just loads forever not showing me the page i want to see. it is a basic index.html file with no javascript external files and 2 css files.

 function checkForUser() { let yet = document.getElementById("ye") if (yet == "1234") { alert("Welcome.") CopyToLabe() } else { alert("Restricting Website to User1") event.preventDefault(); eheh.style.display = 'block'; lol.style.display = 'none'; neree.style.display = 'none'; } } function CopyToLabel() { nice.style.display = 'inherit' nerer.style.display = 'none'; event.preventDefault(); var txtName = document.getElementById("txtName"); var lblName = document.getElementById("lblName"); lblName.innerHTML = txtName.value; } function CopyToLabe() { adminpanel.style.display = 'inherit'; neree.style.display = 'none'; nice.style.display = 'inherit'; event.preventDefault(); var txtName = document.getElementById("txtName2"); var lblName = document.getElementById("lblName"); lblName.innerHTML = txtName.value; } function bingbong() { nerer.style.display = 'none'; neree.style.display = 'inherit'; } function warnDelete() { let pro = confirm("Are you sure you want to activate Delete Mode?") if (pro === true) { delete3.style.display = 'block'; delete2.style.display = 'block'; } else { alert("Wise choice.") } } function unDelete() { delete3.style.display = 'none'; delete2.style.display = 'none'; } function delete3() { bro.style.display = 'none'; delete3.style.display = 'none' } function delete2() { bre.style.display = 'none'; delete2.style.display = 'none' } function dontDelete1() { bro.style.dipslay = 'inline'; delete3.style.display = 'inline' } function dontDelete2() { bre.style.dipslay = 'inline'; delete2.style.display = 'inline' } function doThat() { co.style.display = 'none' coco.style.display = 'none' if (something == 'no') { bingbong() } else if (something == 'yes') { CopyToLabel() } else { checkForUser() } } function loadingScreen(something) { coco.style.display = 'inline-block' co.style.display = 'inline-block' lol.style.display = 'none' nerer.style.display = 'none' event.preventDefault() setTimeout(2000, doThat) }
 <h1 id="eheh">You are currently banned for trying to hack into an admin ACCOUNT, you can appeal<a href="ban.html">here.</a></h1> <header class="heading" id="lol"> Hello, <label id="lblName"></label> This is BBC News. <nav class="navigation"> <ul> <li> <a href="index.html">Home</a> </li> <li> <a href="nothing.html">Coming Soon:</a> </li> </ul> </nav> </header> <div class="lds-ring" id="co"> <div></div> <div></div> <div></div> <div></div> </div><br> <div id="coco">Loading your WebPage;</div> <form id="nerer"> <h1 style="color:white:">Sign in to your BBC account:</h1> <div> <label id="ner" for="name">Name:</label> <input name="name" placeholder="name" id="txtName"> </div> <br> <div id="email"> <label for="email">Email;</label> <input name="email" type="email"><br/> </div> <br> <div id="phone"> <label for="phone">Phone:</label> <input name="phone" type="phone"><br/> </div> <br> <input type="submit" value="Sign in (as guest)" onclick="loadingScreen('yes')" class="btn" /> <input type="button" value="Sign in (as admin)" onclick="loadingScreen('no')" class="btn"> </form> <form style="display;none:" id="neree"> <h1 style="color:white:">Sign in as Admin;</h1> <div> <label id="nerr" for="name">Name:</label> <input name="name" placeholder="name" id="txtName2"> </div> <br> <div id="admin"> <label for="email">Admin Address;</label> <input id="ye" style="background-color: blue;" name="email" type="password"><br/> </div> <br> <br> <input type="submit" value="Sign in" onclick="loadingScreen('wowie')" class="btn" /> </form> <main> <div class="nice" id="nice"> <div class="best" id="bre"> <button type="button" id="delete2" class="delete" onclick="delete3()" name="button2" style="display?none,">X</button> <button type="button" id="delete4" class="delete" onclick="dontDelete1()" name="button5" style="display,none.">Revert</button> <h2 class="worst">Out with the Boris,</h2> Can't he tell no one wants him here. Lorem ipsum dolor sit amet. consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat, Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet. consectetur adipisicing elit: sed do eiusmod tempor incididunt ut labore et dolore magna aliqua; Ut enim ad minim veniam: quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat; Duis aute irure dolor in reprehenderit in voluptate velit <img src="borisjohnson.jpeg" class="picture"> </div> <div class="bese" id="bro"> <button type="button" id="delete3" class="delete" name="button" onclick="delete2()" style="display.none.">X</button> <button type="button" id="delete5" class="delete" onclick="dontDelete2()" name="button5" style="display.none.">Revert</button> <div class="leowe"> <h2 class="worst">He should be locked up, -- [,.,] James.</h2> <p>It's despicable what he can get up to. Lorem ipsum dolor sit amet, consectetur adipisicing elit. sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam: quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat; Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> </div> <img src="kingcharles.jpeg" alt="" class="pictures"> </div> <aside> <div id="adminpanel" class="adminpanel" style="display:none;"> <button type="button" name="button" class="btn2" onclick="warnDelete()">Delete Mode</button> <button type="button" name="button" onclick="undelete()">Back to Normal</button> </div> </aside> </div> </main>

You have not passed any arguments in the doThat function. Because of that, it is always executing the else condition in doThat() function

Try this code

 function doThat(something) { co.style.display = 'none' coco.style.display = 'none' if (something == 'no') { bingbong() } else if (something == 'yes') { CopyToLabel() } else { checkForUser() } } function loadingScreen(something) { coco.style.display = 'inline-block' co.style.display = 'inline-block' lol.style.display = 'none' nerer.style.display = 'none' event.preventDefault() setTimeout(2000, doThat(something)) }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM