0
我擁有一切工作,我想要它。我唯一無法弄清的是如何將JavaScript移動到頁面的絕對左上角。該程序獲取系統日期,然後將其與兩個季節變量進行比較。在比較它們之後,它確定應該顯示哪個圖像。在html文檔上移動javascript
<head>
<title>Date Compare</title>
</head>
<!---
Made by Ben Mason
Email [email protected]
!!! You may change this how you like but please give me credit if you do!!
--->
<body>
<script type="text/javascript">
var a = new Date(); //beginning of Spring
var b = new Date(); //beginning of Summer
var c = new Date(); //beginning of Fall
var d = new Date(); //beginning of Winter
var today = new Date();
//Set actual Dates
a.setFullYear(2012, 2, 20);
b.setFullYear(2012, 5, 20);
c.setFullYear(2012, 8, 22);
d.setFullYear(2012, 11, 21);
//compare today vs dates of seasons
if ((today > a) && (today <= b))
{
document.write("<img src = Images/Spring.jpg>");
}
else if ((today > b) && (today <= c))
{
document.write("<img src = Images/Summer.jpg>");
}
else if ((today > c) && (today <= d)) {
document.write("<img src = Images/Fall.jpg>");
}
else if ((today >= d) || (today <= a)) {
document.write("<img src = Images/Winter.jpg width=320 height=480>");
}
</script>
</body>
</html>