这是一个显示日期的简单功能(我不想要专业的,所以这就足够了)。问题是我想在页面加载时显示它。我不希望用户按下任何按钮或任何东西,但它不起作用。
这里是:
<script type="text/javascript">
window.onload = ReturnDay;
</script>
<script>
function ReturnDay() {
var monthNames = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
];
var dayNames= [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
];
var newDate = new Date();
newDate.setDate(newDate.getDate() + 1);
$('#dateday').html(dayNames[newDate.getDay()] + " " + newDate.getDate() + ' ' + monthNames[newDate.getMonth()] + ' ' + newDate.getFullYear());
}
</script>
<input id="dateday" type=text></div>
有任何想法吗?
非常感谢。