正如標題所述,我期待顯示從countup開始計數以來的日期。 下面是我從網上下了代碼:顯示countup的日期
<html>
<header>
<marquee meta http-equiv="Content-Type" content="text/html;charset=utf8" Class="Scroller" behavior="scroll" direction="left" width="100%" height="50" scrollamount="8" scrolldelay="0" onmouseover="this.stop()" onmouseout="this.start()">
<font size="5" face="Arial, Helvetica, sans-serif">
<strong>
<em>
<script type="text/javascript">
var montharray = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
function countup (yr, m, d) {
var today = new Date()
var todayy = today.getYear()
if (todayy < 1000)
todayy+=1900
var todaym = today.getMonth()
var todayd = today.getDate()
var todaystring = montharray[todaym]+" "+todayd+", "+todayy
var paststring = montharray[m-1]+" "+d+", "+yr
var difference = (Math.round((Date.parse(todaystring) - Date.parse(paststring))/(24 * 60 * 60 * 1000)) * 1)
difference += " jours"
document.write("<FONT COLOR='RED'>Nombre de jours sans accident : " + difference + " Dernier Accident le XX Accident sans arrêt. En chargeant son véhicule, la main du technicien a heurté un tuyau en inox, lui occasionant une plaie au doigt </FONT>")
}
//Entrer la date AAAA/MM/JJ
countup(2016, 05, 04)
</script>
</em>
</header>
<body>
</body>
</html>
HTML代碼打算在我公司 的計數進位工作正常顯示上次工作事故的信息,在「文件後,我想什麼顯示。寫「是在這個例子2016/05/04中的」countup「中設置的日期,是否有這樣做,或者我是否必須手動插入XX日期的日期?
有你嘗試添加'文件撰寫(YR + 「/」 + M + 「/」 + d);'第一文件撰寫後? – moped
我可能做錯了 我試過document.write(yr +「/」+ m +「/」+ d)(「 Nombre de jours sans accident .... and whats displayed is只有日期 如果我用(yr +「/」+ m +「/」+ d)替換「XX」;返回值是NaNa – Ajohnson