JavaScript question

Snitz™ Forums 2000
https://forum.snitz.com/forumTopic/Posts/66991?pagenum=1
05 November 2025, 02:12

Topic


borge
JavaScript question
04 May 2008, 05:53


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?<

 

Replies ...


phy1729
04 May 2008, 10:51


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.<
borge
04 May 2008, 14:47


Thanks, that fixed it smile<
phy1729
04 May 2008, 15:30


You're welcome.<
© 2000-2021 Snitz™ Communications