[英]Js script crashing entire element
Im makig a site on google sites.我在 google 站点上创建了一个站点。 I have a button made by code that detects if you put correct code into the input box and if you put correct one then it should load another site but when I put the code the object crashes.我有一个由代码制作的按钮,它检测您是否将正确的代码放入输入框中,如果您输入正确的代码,那么它应该加载另一个站点,但是当我输入代码时,对象崩溃了。
I've tried a lot of different things but everyone I tried didn't work.我尝试了很多不同的东西,但我尝试过的每个人都没有用。
<form name="form1" method="GET">
<input name="codebox1" type="text" />
<input name="button1" type="submit" value="Check Code" onClick="return testResults(this.form)"/>
</form>
<script>
function testResults (form) {
if (form.codebox1.value == "Doovhhlqjhbh") {
window.location = 'https://sites.google.com/view/the-mbd-project/There-are-secrets-to-be-discovered';
window.alert("Correct Code. Connecting...");
}
else {
window.alert("Wrong Code, try again!");
}
return false;
};
</script>
change your function to this:将您的功能更改为此:
function testResults(form) {
if (form.codebox1.value == "Doovhhlqjhbh") {
window.alert("Correct Code. Connecting...");
setTimeout(() => {
window.location.href = 'https://sites.google.com/view/the-mbd-project/There-are-secrets-to-be-discovered';
}, 0);
}
else { window.alert("Wrong Code, try again!"); }
return false;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.