我使用以下 javascript .. 当它写在 html 文件中时,它可以工作
<script type="text/javascript">
var d=new Date();
var ShowenYear = d.getFullYear();
var Month = d.getMonth();
var NextSeason = "Unknown Season";
if (Month == 1 || Month == 2 || Month == 3) {
NextSeason = "Spring";
}
else if (Month == 4 || Month == 5 || Month == 6) {
NextSeason = "Summer";
}
else if (Month == 7 || Month == 8 || Month == 9) {
NextSeason = "Autumn";
}
else if (Month == 10 || Month == 11 || Month == 12) {
NextSeason = "Winter";
ShowenYear++;
}
document.getElementById("Season").innerHTML = NextSeason + " " + ShowenYear;
</script>
它工作得很好,但是当我创建一个 js 文件时,它全部复制了(完全一样,只是没有脚本标签
然后像这样调用文件
<script type="text/javascript" src="js/showdate.js" ></script>
它根本行不通
感谢愿意帮忙的人