JavaScript question - Postet den (3066 Views)
Junior Member
borge
Innlegg: 185
185
I have been using a small JavaScript to display the current year. It is working well with IE, but I recently discovered that it is not displaying right in Mozilla Firefox.
Code:
<SCRIPT language="JavaScript">
<!--
var today_date= new Date()
var myyear=today_date.getYear()
document.write(myyear)
-->
</script>

Does anyone know what I should so to fix it, or a better way of accomplishing what this script is supposed to do?<
borge
   
 Sidestørrelse 
Postet den
Average Member
phy1729
Innlegg: 589
589
That works fine for me in FF 2.0.0.14 but you may want getFullYear() which will return 2008 not 108 and comment out the --> by using //-->. If you're using a xhtml doctype get rid of the comment altogether because anything in a comment can be ignored by a parser.<
Postet den
Junior Member
borge
Innlegg: 185
185
Thanks, that fixed it smile<
borge
Postet den
Average Member
phy1729
Innlegg: 589
589
You're welcome.<
 
Du må legge inn en melding