<html>
<head><title>test sample a.html</title>
<script type="text/javascript">
<!--
var lastup = new Date(document.lastModified);
var update = Date.parse(lastup);
function test(){
if(typeof(parent.b.update)=="undefined"){
alert("Bの更新日時が読み込まれていません");
return false;
}else if(typeof(parent.c.update)=="undefined"){
alert("Cの更新日時が読み込まれていません");
return false;
}
var arr = (new Array(update, parent.b.update, parent.c.update)).sort().reverse(); // 3つの変数を配列にして降順にソート
lastup.setTime(arr[0]); // lastupにA,B,Cの一番新しい更新日時をセット
var weeks = new Array('日','月','火','水','木','金','土');
var year = lastup.getYear(); // 年
var month = za(lastup.getMonth() + 1); // 月
var day = za(lastup.getDate()); // 日
var week = weeks[ lastup.getDay() ]; // 曜日
var hour = za(lastup.getHours()); // 時
var min = za(lastup.getMinutes()); // 分
var sec = za(lastup.getSeconds()); // 秒
if(year < 2000) { year += 1900; }
// 書き出し
document.all.updatetime.innerHTML='<B>' + year + '年' + month + '月' + day + '日(' + week + ')'+ hour + '時' + min + '分' + sec + '秒</B>';
}
function za (x){
if( x < 10 ){ x = "0" + x; }
return x;
}
//-->
</script>
</head>
<body onload="test()">
<p>更新日時テスト</p>
<p>更新日時は:<span id="updatetime"></span></p>
<iframe src="b.html" width="0" height="0" name="b"></iframe>
<iframe src="c.html" width="0" height="0" name="c"></iframe>
</body>
</html><html> <head><title>test sample b.html</title> <script type="text/javascript"> <!-- var lastup = new Date(document.lastModified); var update = Date.parse(lastup); //--> </script> </head> <body> b.htmlの内容 ・ ・ ・ </body> </html>
<html> <head><title>test sample c.html</title> <script type="text/javascript"> <!-- var lastup = new Date(document.lastModified); var update = Date.parse(lastup); //--> </script> </head> <body> c.htmlの内容 ・ ・ ・ </body> </html>
document.all.updatetime.innerHTML='<B>' + year + '年' + month + '月' + day + '日(' + week + ')'+ hour + '時' + min + '分' + sec + '秒</B>';
↓
document.getElementById("updatetime").innerHTML='<B>' + year + '年' + month + '月' + day + '日(' + week + ')'+ hour + '時' + min + '分' + sec + '秒</B>';<html>
<head><title>test sample a.html</title>
</head>
<body>
<p>更新日時テスト</p>
<p>更新日時は:<span id="updatetime"></span></p>
<iframe src="about:blank" width="0" height="0" name="frame_check"></iframe>
<script type="text/javascript">
<!--
var list_lastModifiead = new Array();
var list_checkURL = ['b.html','c.html'];
var sURL_before;
function za (x){
if( x < 10 ){ x = "0" + x; }
return x;
}
function check()
{
var frame_check = window.frame_check;
if(frame_check != null && frame_check.location.href != sURL_before && frame_check.document.lastModified)
{
list_lastModifiead.push(frame_check.document.lastModified);
if(list_checkURL.length == 0)
{
frame_check.location.href = "about:blank";
list_lastModifiead.sort();
var lastup = new Date(list_lastModifiead.pop());
var weeks = new Array('日','月','火','水','木','金','土');
var year = lastup.getYear(); // 年
var month = za(lastup.getMonth() + 1); // 月
var day = za(lastup.getDate()); // 日
var week = weeks[ lastup.getDay() ]; // 曜日
var hour = za(lastup.getHours()); // 時
var min = za(lastup.getMinutes()); // 分
var sec = za(lastup.getSeconds()); // 秒
if(year < 2000) { year += 1900; }
// 書き出し
document.all.updatetime.innerHTML='<B>' + year + '年' + month + '月' + day + '日(' + week + ')'+ hour + '時' + min + '分' + sec + '秒</B>';
return;
}
sURL_before = frame_check.location.href;
frame_check.location.href = list_checkURL.pop();
}
window.setTimeout(check, 1);
}
if(list_checkURL.length > 0)
{
sURL_before = frame_check.location.href;
window.frame_check.location.href = list_checkURL.pop();
check();
}
//-->
</script>
</body>
</html><html>
<head><title>test sample a.html</title>
</head>
<body>
<p>更新日時テスト</p>
<p>更新日時は:<span id="updatetime"></span></p>
<iframe src="about:blank" width="0" height="0" name="frame_check"></iframe>
<script type="text/javascript">
<!--
var list_lastModified = [document.lastModified];
var list_checkURL = ['b.html','c.html'];
var sURL_before;
function za (x){
if( x < 10 ){ x = "0" + x; }
return x;
}
function check()
{
var frame_check = window.frame_check;
if(frame_check != null && frame_check.location.href != sURL_before && frame_check.document.lastModified)
{
list_lastModified.push(frame_check.document.lastModified);
if(list_checkURL.length == 0)
{
frame_check.location.href = "about:blank";
list_lastModified.sort();
var lastup = new Date(list_lastModified.pop());
var weeks = new Array('日','月','火','水','木','金','土');
var year = lastup.getFullYear(); // 年
var month = za(lastup.getMonth() + 1); // 月
var day = za(lastup.getDate()); // 日
var week = weeks[ lastup.getDay() ]; // 曜日
// 書き出し
document.getElementById("updatetime").innerHTML='<B>' + year + '年' + month + '月' + day + '日(' + week + ')</B>';
return;
}
sURL_before = frame_check.location.href;
frame_check.location.href = list_checkURL.pop();
}
window.setTimeout(check, 1);
}
if(list_checkURL.length > 0)
{
sURL_before = frame_check.location.href;
window.frame_check.location.href = list_checkURL.pop();
check();
}
//-->
</script>
</body>
</html>
index.html
---------------
<html>
<head><title>test sample a.html</title>
</head>
<body>
<script type="text/javascript" src="ck_lastModified.js?file=b.html,c.html&addme=true"></script>
<script type="text/javascript" src="ck_lastModified.js?file=table.htm&addme=false"></script>
</body>
</html>
ck_lastModified.js
--------------------
function ck_lastModified()
{
var node_frame = document.createElement("iframe");
node_frame.setAttribute("name", "node_frame");
node_frame.setAttribute("src", "about:blank");
node_frame.setAttribute("width", "0");
node_frame.setAttribute("height", "0");
var nodes_script = document.getElementsByTagName("script");
var node_script = nodes_script[nodes_script.length-1];
node_script.parentNode.insertBefore(node_frame, node_script);
var frame_check = window.frames[window.frames.length-1];
var list_lastModified = new Array();
var list_checkURL = new Array();
var sURL_script = node_script.getAttribute("src");
var list_args = sURL_script.substr(sURL_script.indexOf("?")+1).split("\&");
var list_arg;
for(var i=0; i<list_args.length; i++)
{
list_arg = list_args[i].split("=");
if(list_arg.length != 2)
continue;
switch(list_arg[0])
{
case "file":
list_checkURL = list_arg[1].replace(/\s/g, "").split(",");
break;
case "addme":
if(list_arg[1].replace(/\s/g, "").toLowerCase() == "true")
list_lastModified.push(document.lastModified);
break;
}
}
var sURL_before;
function za (x)
{
if( x < 10 ){ x = "0" + x; }
return x;
}
function check()
{
if(frame_check != null && frame_check.location.href != sURL_before && frame_check.document.lastModified)
{
list_lastModified.push(frame_check.document.lastModified);
if(list_checkURL.length == 0)
{
frame_check.location.href = "about:blank";
list_lastModified.sort();
var lastup = new Date(list_lastModified.pop());
var weeks = new Array('日','月','火','水','木','金','土');
var year = lastup.getFullYear(); // 年
var month = za(lastup.getMonth() + 1); // 月
var day = za(lastup.getDate()); // 日
var week = weeks[ lastup.getDay() ]; // 曜日
// 書き出し
var node_b = document.createElement("b");
node_b.appendChild(document.createTextNode(year + '年' + month + '月' + day + '日(' + week + ')'));
node_frame.parentNode.insertBefore(node_b, node_frame);
node_frame.parentNode.removeChild(node_frame);
return;
}
sURL_before = frame_check.location.href;
frame_check.location.href = list_checkURL.pop();
}
window.setTimeout(check, 1);
}
if(list_checkURL.length > 0)
{
sURL_before = frame_check.location.href;
frame_check.location.href = list_checkURL.pop();
check();
}
}
ck_lastModified();