<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<META http-equiv="Content-Style-Type" content="text/css">
<title>Cookieでメッセージを変更</title>
<script language="JavaScript">
<!--
//クッキーを設定する関数set_cookie
function set_cookie(cook_name,value_str,exp_d) {
if (exp_d == 0) {
expire_text = "";
expire_day = "";
}
else {
expire_day = new Date();
expire_day.setTime(expire_day.getTime() + (exp_d * 24 * 60 * 60 * 1000));
expire_day = expire_day.toGMTString();
expire_text = "expires=";
}
document.cookie = cook_name + "=" + escape(value_str) + "; " + expire_text + expire_day;
}
//クッキーを読み込む関数read_cookie
function read_cookie(strings){
cookie_data=document.cookie+";";
first_pos=cookie_data.indexOf(strings,0);
if(first_pos!=-1){
first_pos += (strings.length+1);
end_pos=cookie_data.indexOf(";",first_pos);
value=cookie_data.substring(first_pos,end_pos);
return(unescape(value));
}
return("");
}
past_times = read_cookie("TIMES");//クッキーを読み込んで訪問回数を取得する
if (past_times == "") {//訪問回数に何も入っていなかったら一回目の訪問である
past_times = 1;
}
houmon_times = eval(past_times) + 1; //訪問回数に1を足す
past_date = read_cookie("DATE");//クッキーを読み込んで前回の訪問日付を取得する
if (past_date == "") {//日付に何も入っていなかったら一回目の訪問である
past_date = "なし";
}
//現在の訪問時間を取得する
var now = new Date();
if ( now.getYear() >= 2000 ){
now_year = now.getYear();
}
else {
now_year = now.getYear()+1900;
}
now_month = now.getMonth()+1;
now_day = now.getDate();
now_hour = now.getHours();
now_minute = now.getMinutes();
now_date = now_year + "/" + now_month + "/" + now_day + " " + now_hour + ":" + now_minute;
//Cookie書き込み(名前,その値,クッキー保存日数)で指定する
set_cookie("TIMES", houmon_times, 1);
set_cookie("DATE", now_date, 1);
//ブラウザに表示する関数cookie_display
function cookie_display(){
document.write("訪問回数:" + past_times + "<br>");
document.write("前回の訪問日:" + past_date + "<br>");
}
//-->
</script>
<style type="text/css">
<!--
body { text-align: center;}
-->
</style>
</head>
<body bgcolor="#FFFFFF">
<table border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td align="center" colspan="4">
<p><img src="welcome.gif" width="400" height="50"></p>
</td>
</tr>
<tr>
<td align="center"><img src="music.gif" width="100" height="30"></td>
<td align="center"><img src="movie.gif" width="100" height="30"></td>
<td align="center"><img src="bbs.gif" width="100" height="30"></td>
<td align="center"><img src="link.gif" width="100" height="30"></td>
</tr>
<tr>
<td align="center" colspan="4">
<script language="JavaScript">
<!--
cookie_display();
//-->
</script>
</td>
</tr>
</table>
</body>
</html>