Ecco un semplice codice che ho buttato giù:
Codice:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Mostra età</title>
<script type="text/javascript">
<!--
function get_age (d, m, y)
{
dt = new Date ();
dt_d = dt.getDate ();
dt_m = dt.getMonth () + 1;
dt_y = dt.getYear () + 1900;
age = dt_y - y;
if ((dt_d < d && dt_m == m) || dt_m < m)
age--;
return age;
}
//-->
</script>
</head>
<body>
<script type="text/javascript">
<!--
document.writeln ("Ciao, io sono Andrea ed ho " + get_age (9, 11, 1973) + " anni.");
//-->
</script>
</body>
</html>
Spero di non aver fatto errori. La logica di calcolo dell'età
dovrebbe essere giusta.