Forum de discussion
Forum « Programmation Javascript » (archives)
Re: Changement de répertoir en fonction de la date
Envoyé: 29 juillet 2004, 2h59 par Hack_Track
<html>
<!--
Author: Philippe Fery
Creation: July 29, 2004
philippefery@hotmail.com
-->
<head>
<title>Sélection d'un répertoire en fonction de la date</title>
<script language="javascript" type="text/javascript">
function getDirectoryFromDate(d){
month = ""+d.getMonth();
day=""+d.getDate();
formattedDate="";
formattedDate+=(month.length<2?"0":"");
formattedDate+=month;
formattedDate+=(day.length<2?"0":"");
formattedDate+=day;
var season = "";
if(formattedDate<221){
season = "winter";
}else if(formattedDate<521){
season = "spring";
}else if(formattedDate<821){
season = "summer";
}else if(formattedDate<1121){
season = "falls";
}else{
season = "winter";
}
directory="/images/"+season+"/";
alert("We are in "+season+". The directory is "+directory);
}
</script>
</head>
<body>
<script language="javascript" type="text/javascript">
today = new Date();
getDirectoryFromDate(today);
</script>
</body>
</html>
;-)
HackTrack
Réponses
|