日期:2014-05-16  浏览次数:20361 次

年月js控件,没有日
效果如下图:



aaa.html
<html>
<head>
<title>商品状态数据</title>

<script language="JavaScript" src="yeardate.js"></script>

</head>
<body >
年月js控件:<input type="text" name="remark" id="remark" onfocus="setMonth(this);" > 
							
							
</body>

</html>



yeardate.js
var strFrame;
//日历用iframe实现        
document.writeln('<iframe id=MMDateLayer  frameborder=no scrolling=no Author=MM style="position: absolute; width: 145; height: 46; z-index: 9998;display=none"></iframe>')
//ifram中用div定位
strFrame+='<div style="z-index:9999;position: absolute; left:0; top:0;" onselectstart="return false">'
strFrame+='<span id=tmpMMSelectYearLayer  style="z-index: 9999;position: absolute;top: 2; left: 18;display: none"></span>';
strFrame+='<span id=tmpMMSelectMonthLayer style="z-index: 9999;position: absolute;top: 2; left: 75;display: none"></span>';
strFrame+='<table border=0 cellspacing=1 cellpadding=0 width=142 height=23 bgcolor=#808080 onselectstart="return false" Author=MM>';
strFrame+='<tr>';
strFrame+='<td width=142 height=23 bgcolor=#FFFFFF>';
strFrame+='<table border=0 cellspacing=1 cellpadding=0 width=140 height=23 Author=MM>';
strFrame+='<tr align=center>'
strFrame+='<td width=20 Author=MM align=center bgcolor=#808080 style="font-size:12px;cursor: hand;color: #FFD700" ';
strFrame+=' onclick="parent.MMPrevM()" title="向前翻月" ><b Author=MM>&lt;&lt;</b>';
strFrame+=' </td>'
strFrame+='<td width=60 align=right style="font-size:12px;cursor:default" title="点击这里选择年份">';
strFrame+=' <span width=60 Author=MM id=MMYearHead onclick="parent.MMSelectYearInnerHTML(this.innerText)"></span>&nbsp;年&nbsp;';
strFrame+='</span>';
strFrame+='</td>';
strFrame+='<td width=48 align=left style="font-size:12px;cursor:default" title="点击这里选择月份">';
strFrame+='<span  id=MMMonthHead Author=MM onclick="parent.MMSelectMonthInnerHTML(this.innerText)"></span>&nbsp;月';
strFrame+='</td>';
strFrame+=' <td width=20 bgcolor=#808080 align=center style="font-size:12px;cursor: hand;color: #FFD700" ';
strFrame+=' onclick="parent.MMNextM()" title="往后翻月" Author=MM><b Author=MM>&gt;&gt;</b></td></tr>';
strFrame+=' </table></td></tr>';

strFrame+=' <tr><td width=142 height=18 bgcolor=#808080>';
strFrame+='<table border=0 cellspacing=0 cellpadding=0 width=140 height=1 style="cursor:default">';
strFrame+='<tr align=center><td style="font-size:12px;color:#FFFFFF" Author=MM></td>';
strFrame+='<td style="font-size:12px;color:#FFFFFF" Author=MM></td><td style="font-size:12px;color:#FFFFFF" Author=MM></td>';
strFrame+='<td style="font-size:12px;color:#FFFFFF" Author=MM  onclick=parent.MMDayClick(this.innerText)>确定</td>';
strFrame+='<td style="font-size:12px;color:#FFFFFF" Author=MM  onclick=parent.MMDayClick(this.innerText)>清空</td></tr>';
strFrame+='</table></td></tr>';
strFrame+='  </table></div>';
window.frames.MMDateLayer.document.writeln(strFrame); 
window.frames.MMDateLayer.document.close();        //解决ie进度条不结束的问题 


var MMoutObject;
var MModatelayer=window.frames.MMDateLayer.document.all;        //存放日历对象 

function setMonth(tt,obj) //主调函数 
{ 
    
    if (arguments.length > 2){alert("对不起!传入本控件的参数太多!");return;} 
    if (arguments.length == 0){alert("对不起!您没有传回本控件任何参数!");return;} 
    var dads = document.all.MMDateLayer.style; 
    var th = tt; 
    var ttop = tt.offsetTop; //TT控件的定位点高 
    var thei = tt.clientHeight; //TT控件本身的高 
    var tleft = tt.offsetLeft; //TT控件的定位点宽 
    var ttyp = tt.type; //TT控件的类