【发布时间】:2019-01-09 14:41:36
【问题描述】:
天哪,我已经厌倦了自己想办法解决这个问题。我在 Chrome 和 Firefox 中使用开发人员工具,并且不断收到 SyntaxError: Unexpected Token <. youtube w3schools.com>
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>Invitation Page</title>
<link rel="stylesheet" type="text/css" href="css/main.css" />
</head>
<script>
function showFormInput() { //get data from the form
var a1 = document.getElementById('rname').value; // 'rname reference
// id in html(not included with html you will need to add.)
var b2 = document.getElementById('orgname').value;
var c3 = document.getElementById('date').value;
var d4 = document.getElementById('web').value;
var e5 = document.getElementById('hname').value;
document.getElementById('recipientName').innerHTML = a1; // 'recipientName
// reference name in the html
document.getElementById('organizationName').innerHTML = b2;
document.getElementById('eventDate').innerHTML = c3;
document.getElementById('websiteURL').innerHTML = d4;
document.getElementById('hostName').innerHTML = e5;
}
</script>
<body>
<header>
<div class="top">
<a class="logo" href="index.html">CapellaVolunteers<span
class="dotcom">.org</span></a>
</div>
<nav>
<ul class="topnav">
<li><a href="index.html">Home</a></li>
<li><a href="invitation.html" class="active">Invitation</a></li>
<li><a href="gallery.html">Gallery</a></li>
<li><a href="registration.html">Registration</a></li>
</ul>
</nav>
</header>
<section id="pageForm">
<label for="recipientName">Recipient name:</label>
<input type="text" id="rname" name="recipientName" placeholder="Enter your
Recipient Name" />
<label for="organizationName">Organization name:</label>
<input type="text" id="orgname" name="organizationName" placeholder="Enter
your Organization Name" />
<label for="eventDate">Event Date:</label>
<input type="text" id="date" name="eventDate" placeholder="Enter your
Event Date" />
<label for="websiteURL">URL:</label>
<input type="text" id="web" name="websiteURL" placeholder="Enter your
Website URL" />
<label for="hostName">Host name:</label>
<input type="text" id="hname" name="hostName" placeholder="Host Name" />
<input type="submit" value="Submit" onclick="showFormInput()" />
</section>
<article id="placeholderContent">
<br/>
<br/>
Hello
<span id="recipientName">recipientName</span>!
<br/>
<br/> You have been invited to volunteer for an event held by
<span id="organizationName">organizationName</span> on
<span id="eventDate">eventDate</span>. Please come to the following
website:
<span id="websiteURL">websiteURL</span> to sign up as a volunteer.
<br/>
<br/> Thanks!
<br/>
<br/>
<span id="hostName">hostName</span>
</article>
<footer>This events site is for IT-FP3215 tasks.</footer>
</body>
</html>
【问题讨论】:
-
您从服务器发送什么
Content-Type标头? -
你的代码还能用吗?
-
您有一个不在您的头部或身体内部的脚本标签。
-
对 JavaScript 来说非常新,所以我假设你问我它是 text/html 还是 text/plain?我正在使用文本/html。这有帮助吗?如果不是,请为我再笨一点。谢谢你。 :-)
-
我已经把脚本标签放在了底部,我仍然得到同样的错误。
标签: javascript html syntax-error doctype