我的HTML只是加载永远当我按下按钮



当我按下按钮时,应该有一个超时功能(带有加载屏幕)2秒,然后它将您发送到页面。由于一些未知的原因,它不工作,只是加载永远不显示我想要看到的页面!它是一个基本的index.html文件,没有javascript外部文件和2个CSS文件。

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>

您没有在doThat函数中传递任何参数。因此,它总是执行doThat()函数

中的else条件试试这个代码

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))
}

最新更新