<続きです>
<script type="text/javascript">
<!--
var miniPop = {};
miniPop.init = function() {
div = document.getElementById('mini').style.display = "none";
this.set();
var b = document.body;
try {
b.addEventListener('click', function(e){ miniPop.click(e) },true);
} catch(e) {
b.attachEvent('onclick', function(e){ miniPop.click(e) });
}
}
miniPop.set = function(d) {
var div = document.getElementById('mini');
if (!d) {
d = new Date(), this.y = d.getFullYear(), this.m = d.getMonth();
} else {
this.m += d, this.y += (this.m<0 || this.m>11)?d:0, this.m = (this.m+12)%12;
}
div.getElementsByTagName('DIV')[1].innerHTML = this.calendar(this.y, this.m);
}
miniPop.calendar = function(y, m) {
var c, x, b, h;
c = -new Date(y, m).getDay(x = new Date(y, ++m, 0).getDate(b = -1));
h = '<table><tr><th class="prev"><<</th><th colspan="5">';
h += y + '/' + m + '</th><th class="next">>></th></tr><tr>';
h += '日月火水木金土'.replace(/(.)/g,'<th>$1</th>');
while ((b++>5?b=0:b) | c<x) {
h += (b?'':'</tr><tr>') + '<td' + (b==6?' class="sat">':b==0?' class="sun">':'>');
h += (++c<1 | c>x?'-':c) + '</td>';
}
return h + '</tr></table>';
}
miniPop.click = function(evt) {
var t = evt.srcElement || evt.target, p = t.parentNode;
var styl = document.getElementById("mini").style;
while (p && p.nodeName != "DIV") p = p.parentNode;
if (p && p.parentNode.id == "mini") {
if (t.nodeName == "TH" && (d = {next:1, prev:-1}[t.className])) this.set(d);
if (t.nodeName == "BUTTON") styl.display = "none";
} else {
if (styl.display != "none") return;
var dc = document.compatMode?document.body:document.documentElement;
styl.top = (window.pageYOffset || dc.scrollTop) + evt.clientY;
styl.left = (window.pageXOffset || dc.scrollLeft) + evt.clientX;
styl.display = "block";
}
}
miniPop.init();
//-->
</script>
</body>
</html>
お礼
まさしくこのような処理を探していました。 今あるシステムにかなりそのまま利用できそうなくらいに良い感じです。 ありがとうございました。