【发布时间】:2020-05-10 00:49:07
【问题描述】:
我无法重定向到下一页。请帮我。我有一个项目明天到期。我已经尝试了五个多小时。请帮我。我求求你们了。我不知道我做错了什么。我对 Javascript 很陌生。
请告诉我我做错了什么
document.getElementById("one").onclick = function() {
location.href = "lessons.html"
};
<!DOCTYPE html>
<html>
<head>
<title> MaxFluency Tutorials Page</title>
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="tutorial.css">
</script>
</head>
<body>
<header>
<div class="topbar">
<center>
<p> Tutorials</p>
</center>
</header>
</div>
<div class="lessons">
<center>
<button class=les id=one type="button"> <h3> Lesson 1: </h3> Nature of Communication </button>
<button class=les id="2nd"> <h3>Lesson 2:</h3></button>
<button class="les" id="3rd"> <h3>Lesson 3:</h3></button>
</center>
</div>
<div class="nav">
<center><button class="loc"> Home</button>
<button class="loc"> Highscores </button>
<button class="loc"> Support us!</button>
</center>
</div>
<script type="text/Javascript" src="tutorials.js">
</script>
</body>
</html>
【问题讨论】:
-
您有一些格式错误的 html。例如
class=les id=one应该是class="les" id="one"。 -
@Gavin 不包含特殊字符的属性值不需要引号。
-
课程.html 的路径是什么?该网站的网址是什么?这是做什么的:
-
你只是有很多 html 语法错误需要修复。
-
我将 tutorials.js 作为 html 的外部文件。 Lessons.html 是它应该重定向到的地方
标签: javascript html button href