最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

JavaScript實(shí)現(xiàn)的日期控件具體代碼

 更新時間:2013年11月18日 16:24:12   作者:  
JavaScript實(shí)現(xiàn)的日期控件,它還會讀取當(dāng)前的時間,有需要的朋友可以參考一下

復(fù)制代碼 代碼如下:

<html>
<head>
<style>
<!--
.wr{font-size: 12pt; line-height: 22px}
.wr1 {  FONT-SIZE: 12px; LINE-HEIGHT: 200%}
.wr2 {  FONT-SIZE: 14px; LINE-HEIGHT: 200%}
.wr3 {  FONT-SIZE: 12px}
.wr4 {  FONT-SIZE: 12px; LINE-HEIGHT: 150%}
// -->
</style>

<title>日期自動輸入控件</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<style type="text/css">
.date-picker-wp {
display: none;
position: absolute;
background: #f1f1f1;
left: 40px;
top: 40px;
border-top: 4px solid #3879d9;
}
.date-picker-wp table {
border: 1px solid #ddd;
}
.date-picker-wp td {
background: #fafafa;
width: 22px;
height: 18px;
border: 1px solid #ccc;
font-size: 12px;
text-align: center;
}
.date-picker-wp td.noborder {
border: none;
background: none;
}
.date-picker-wp td a {
color: #1c93c4;
text-decoration: none;
}
.strong {font-weight: bold}
.hand {cursor: pointer; color: #3879d9}
</style>

<script type="text/javascript">
var DatePicker = function () {
var $ = function (i) 
{
   return document.getElementById(i)
},
addEvent = function (o, e, f) {o.addEventListener ? o.addEventListener(e, f, false) : o.attachEvent('on'+e, function(){f.call(o)})},
getPos = function (el) {
for (var pos = {x:0, y:0}; el; el = el.offsetParent) {
pos.x += el.offsetLeft;
pos.y += el.offsetTop;
}
return pos;
};
var init = function (n, config) {
window[n] = this;
Date.prototype._fd = function () {var d = new Date(this); d.setDate(1); return d.getDay()};
Date.prototype._fc = function () {var d1 = new Date(this), d2 = new Date(this); d1.setDate(1); d2.setDate(1); d2.setMonth(d2.getMonth()+1); return (d2-d1)/86400000;};
this.n = n;
this.config = config;
this.D = new Date;
this.el = $(config.inputId);
this.el.title = this.n+'DatePicker';
this.update();
this.bind();
};
init.prototype = {
update : function (y, m) {
var con = [], week = ['Su','Mo','Tu','We','Th','Fr','Sa'], D = this.D, _this = this;
fn = function (a, b) {return '<td title="'+_this.n+'DatePicker" class="noborder hand" onclick="'+_this.n+'.update('+a+')">'+b+'</td>'},
_html = '<table cellpadding=0 cellspacing=2>';
y && D.setYear(D.getFullYear() + y);
m && D.setMonth(D.getMonth() + m);
var year = D.getFullYear(), month = D.getMonth() + 1, date = D.getDate();
for (var i=0; i<week.length; i++) con.push('<td title="'+this.n+'DatePicker" class="noborder">'+week[i]+'</td>');
for (var i=0; i<D._fd(); i++ ) con.push('<td title="'+this.n+'DatePicker" class="noborder"> </td>');
for (var i=0; i<D._fc(); i++ ) con.push('<td class="hand" onclick="'+this.n+'.fillInput('+year+', '+month+', '+(i+1)+')">'+(i+1)+'</td>');
var toend = con.length%7;
if (toend != 0) for (var i=0; i<7-toend; i++) con.push('<td class="noborder"> </td>');
_html += '<tr>'+fn("-1, null", "<<")+fn("null, -1", "<")+'<td title="'+this.n+'DatePicker" colspan=3 class="strong">'+year+'/'+month+'/'+date+'</td>'+fn("null, 1", ">")+fn("1, null", ">>")+'</tr>';
for (var i=0; i<con.length; i++) _html += (i==0 ? '<tr>' : i%7==0 ? '</tr><tr>' : '') + con[i] + (i == con.length-1 ? '</tr>' : '');
!!this.box ? this.box.innerHTML = _html : this.createBox(_html);
},
fillInput : function (y, m, d) {
var s = this.config.seprator || '/';
this.el.value = y + s + m + s + d;
this.box.style.display = 'none';
},
show : function () {
var s = this.box.style, is = this.mask.style;
s['left'] = is['left'] = getPos(this.el).x + 'px';
s['top'] = is['top'] = getPos(this.el).y + this.el.offsetHeight + 'px';
s['display'] = is['display'] = 'block';
is['width'] = this.box.offsetWidth - 2 + 'px';
is['height'] = this.box.offsetHeight - 2 + 'px';
},
hide : function () {
this.box.style.display = 'none';
this.mask.style.display = 'none';
},
bind : function () {
var _this = this;
addEvent(document, 'click', function (e) {
e = e || window.event;
var t = e.target || e.srcElement;
if (t.title != _this.n+'DatePicker') {_this.hide()} else {_this.show()}
});
},
createBox : function (html) {
var box = this.box = document.createElement('div'), mask = this.mask = document.createElement('iframe');
box.className = this.config.className || 'datepicker';
mask.src = 'javascript:false';
mask.frameBorder = 0;
box.style.cssText = 'position:absolute;display:none;z-index:9999';
mask.style.cssText = 'position:absolute;display:none;z-index:9998';
box.title = this.n+'DatePicker';
box.innerHTML = html;
document.body.appendChild(box);
document.body.appendChild(mask);
return box;
}
};
return init;
}();
onload = function () {
new DatePicker('_DatePicker_demo', {
inputId: 'date-input',
className: 'date-picker-wp',
seprator: '-'
});
}
</script>

<body bgcolor="#FFFFDB" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<form >

  <table border="0" width="60%" align="center">

   <tr>
     <td width="45%" class="wr4" align="right"> 生日:</td>
     <td width="55%" class="wr4">
         <input type="text" name="mtime" id="date-input">  <font color="RED">*</font>        
     </td>

   </tr>

  <tr> 
     <td width="45%" align="right"><input type = "submit" value = "確定"/></td> 
     <td width="55%"><input type = "reset" value = "重置"/></td> 
  </tr>
</table>

</form>
</body>
</html>

html頁面中的js執(zhí)行順序:
1) 在head標(biāo)簽內(nèi)的最先執(zhí)行
2) 在body標(biāo)簽內(nèi)的 執(zhí)行
3) 當(dāng)在 body標(biāo)簽中 加了 onload  事件時 對應(yīng)的 js 最后執(zhí)行,也就是當(dāng)頁面加載完在執(zhí)行

注意:當(dāng)在 body標(biāo)簽中 加了 onload  事件時 在head標(biāo)簽內(nèi),所引用外部的 js 不起作用,當(dāng)換成 在body 內(nèi)部或</html>之上引用外部js時可正常引用

相關(guān)文章

  • js實(shí)現(xiàn)簡單日歷效果

    js實(shí)現(xiàn)簡單日歷效果

    這篇文章主要為大家詳細(xì)介紹了js實(shí)現(xiàn)簡單日歷效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-05-05
  • 使用JS模擬錨點(diǎn)跳轉(zhuǎn)的實(shí)例

    使用JS模擬錨點(diǎn)跳轉(zhuǎn)的實(shí)例

    下面小編就為大家分享一篇使用JS模擬錨點(diǎn)跳轉(zhuǎn)的實(shí)例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-02-02
  • 淺談JavaScript 聲明提升

    淺談JavaScript 聲明提升

    這篇文章主要介紹了JavaScript 聲明提升的相關(guān)資料,幫助大家更好的理解和學(xué)習(xí)JavaScript,感興趣的朋友可以了解下
    2020-09-09
  • 微信JS接口大全

    微信JS接口大全

    這篇文章主要為大家分享了最全面詳細(xì)的微信JS接口大全,希望對大家有幫助,感興趣的小伙伴們可以參考一下
    2016-08-08
  • JavaScipt中棧的實(shí)現(xiàn)方法

    JavaScipt中棧的實(shí)現(xiàn)方法

    這篇文章主要介紹了JavaScript數(shù)據(jù)結(jié)構(gòu)與算法之棧詳解,本文講解了對棧的操作、對棧的實(shí)現(xiàn)實(shí)例等內(nèi)容,需要的朋友可以參考下
    2016-02-02
  • 利用xlsx.js讀取excel文件的詳細(xì)過程

    利用xlsx.js讀取excel文件的詳細(xì)過程

    如果你需要在瀏覽器端處理Excel文件,那么xlsx.js可能是一個不錯的選擇,這篇文章主要介紹了利用xlsx.js讀取excel文件的詳細(xì)過程,文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2025-04-04
  • Bootstrap編寫一個同時適用于PC、平板、手機(jī)的登陸頁面

    Bootstrap編寫一個同時適用于PC、平板、手機(jī)的登陸頁面

    這篇文章主要為大家詳細(xì)介紹了Bootstrap編寫一個同時適用于PC、平板、手機(jī)的登陸頁面,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-06-06
  • JavaScript Window.open彈窗使用詳解

    JavaScript Window.open彈窗使用詳解

    這篇文章主要為大家介紹了JavaScript Window.open 彈窗使用詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-11-11
  • JS 使用for循環(huán)遍歷子節(jié)點(diǎn)查找元素

    JS 使用for循環(huán)遍歷子節(jié)點(diǎn)查找元素

    這篇文章主要介紹了JS 使用for循環(huán)配合數(shù)組遍歷子節(jié)點(diǎn)查找元素,經(jīng)測試,效果不錯,需要的朋友可以看看
    2014-09-09
  • JavaScript中常用數(shù)據(jù)處理函數(shù)groupBy的用法詳解

    JavaScript中常用數(shù)據(jù)處理函數(shù)groupBy的用法詳解

    數(shù)據(jù)處理與分析中,對數(shù)據(jù)進(jìn)行分組是非常常見的功能,不論是實(shí)際工作中,還是在面試的場景中應(yīng)用十分廣泛,尤其在函數(shù)式編程中?groupBy?十分常見,下面我們就來學(xué)習(xí)一下groupBy的用法吧
    2023-12-12

最新評論

诏安县| 上思县| 菏泽市| 荣成市| 卢龙县| 石首市| 神农架林区| 哈尔滨市| 巴楚县| 山西省| 锡林郭勒盟| 都匀市| 牡丹江市| 株洲市| 饶平县| 西畴县| 高阳县| 河津市| 英超| 天峻县| 阿克陶县| 承德市| 临安市| 泗洪县| 阜平县| 根河市| 巨鹿县| 纳雍县| 寿光市| 巴林右旗| 札达县| 雷山县| 铅山县| 时尚| 房产| 延津县| 莎车县| 吉安市| 元谋县| 祥云县| 浙江省|