Javascript 在此行发现多个注释:结束标记 (</script>) 未正确关闭,预期 >

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10271591/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 00:37:03  来源:igfitidea点击:

Multiple annotations found at this line: End tag (</script>) not closed properly, expected >

javascripthtmljsp

提问by somnathchakrabarti

I have written the below html code with the embedded javascript function disableReturnDate() within the script tags. But on the close tag is giving an error

我已经在脚本标签中使用嵌入式 javascript 函数 disableReturnDate() 编写了以下 html 代码。但是在关闭标签上出现错误

*Error*

*错误*

Multiple annotations found at this line:
  - End tag (</script>) not closed properly, expected >.
  - Unknown tag (script function addReturnDate() { if (document.getElementById('RoundTrip').checked) 
   { document.write("Select Return Date:"); document.write("<script>DateInput('returndate',true,'DD-MON-YYYY');"); 
   document.write("<input type=\"button\" onClick=\"alert(this.form.returndate.value)\" value=\"Show date value 
   passed\">"); } } </script> ).
  - End tag of element <script>
Multiple annotations found at this line:
  - End tag (</script>) not closed properly, expected >.
  - Unknown tag (script function addReturnDate() { if (document.getElementById('RoundTrip').checked) 
   { document.write("Select Return Date:"); document.write("<script>DateInput('returndate',true,'DD-MON-YYYY');"); 
   document.write("<input type=\"button\" onClick=\"alert(this.form.returndate.value)\" value=\"Show date value 
   passed\">"); } } </script> ).
  - End tag of element <script>

*Code*

*代码*

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Enter Date-Time, Arrival and Departure Location</title>
<script type="text/javascript" src="calendarDateInput.js"></script>
<script type="text/javascript">
function disableReturnDate() {
    this.form1.returndate.disabled=true;
}
</script>
</head>
<body onload="disableReturnDate()">
<form name="form1" method="post" action="retrievePossibleRoutes.jsp">
Select Travel Date:  
<script>DateInput('traveldate',true,'DD-MON-YYYY');</script> 
<input type="button" onClick="alert(this.form.traveldate.value)" value="Show date value passed">
<br>
Select Return Date:  
<script>DateInput('returndate',true,'DD-MON-YYYY');</script> 
<input type="button" onClick="alert(this.form.returndate.value)" value="Show date value passed">
<input type="radio" name="journeyType" id="OneWay" onClick="disableReturnDate()" checked>One Way<br>
<input type="radio" name="journeyType" id="RoundTrip" onClick="enableReturnDate()">Round Trip<br> 
<br>
Select Departure Location:
<select name="comboDep">
<option></option>
<option></option>
</select>
<input type="submit"/>
<br>
Select Arrival Location:
<select name="comboArrv">
<option></option>
<option></option>
</select>
<input type="submit"/>
</form>
</body>
</html>

Any idea what's wrong. The code being shown in the error was written before but I have removed that now and it still shows in the error message. Look forward to replies

知道出了什么问题。错误中显示的代码是以前编写的,但我现在已将其删除,它仍然显示在错误消息中。期待回复

P.S. The link to the calendarDateInput.js is http://www.dynamicdrive.com/dynamicindex7/jasoncalendar.htm

PS日历DateInput.js的链接是http://www.dynamicdrive.com/dynamicindex7/jasoncalendar.htm

回答by iND

You can verify HTML by using the W3C validator: http://validator.w3.org/check

您可以使用 W3C 验证器验证 HTML:http: //validator.w3.org/check

Two errors of significance show up. Put

出现了两个重要的错误。放

<!doctype html>

at the start of the HTML (you can specify more info in the doctypetag, so look into this a bit more), and add make sure that all tags have the typeattribute set:

在 HTML 的开头(你可以在doctype标签中指定更多信息,所以多看看这个),并添加确保所有标签都type设置了属性:

<script type="text/javascript">

回答by user123444555621

The code being shown in the error was written before but I have removed that now and it still shows in the error message

错误中显示的代码是之前编写的,但我现在已将其删除,它仍然显示在错误消息中

That means that your browser has cached the old version. Clear your cacheand try again.

这意味着您的浏览器已缓存旧版本。清除缓存并重试。