複製代碼 代碼如下:var getMonthWeek = function (a, b, c) { /* a = d = 當前日期 b = 6 - w = 當前周的還有幾天過完(不算今天) a + b 的和在除以7 就是當天是當前月份的第幾周 */ var date = new Date(a, parseInt(b) - 1, c), w = date.getDay(), d = date.getDate(); return Math.ceil( (d + 6 - w) / 7 ); };
但是,如果你想顯示不同地區的時間—--例如,如果你的本部在別的國家,你想查看“本國”時間而非當地時間,又該怎麼辦呢?要做到這一點,必須進行各種時間計算才能將當地時間轉換為目的時間。本文將解釋如何進行這些計算。 第一步: 事情的第一步是獲得當地時間。在JavaScript中,這無疑可以通過初始化一個Data()對象來輕鬆完成。 // create Date object for current location d = new Date();
//用於日期的文字框 name = "indate" function check1(Form) { for (i = 0; i < Form.length; i++) { if (Form.elements[i].value == "") { alert("請填寫完整!") Form.elements[i].focus(); return; } if (Form.elements[i].name == "indate") { var date =
示範樣本 1.圖片和放大使用不同的圖片(大小圖片要比例相同)也可以指定放大倍數(相對於小圖片計算) new imageZoom("img1",{ //mul:6,//指定放大的倍數 onShow:function() { document.title="show,you are moving on the image."; }, onHide:function() { document.title="you mouse move out the image"; },
雲棲社區整合篇,歡迎轉載。複製代碼 代碼如下:function controlImg(ele,w,h){ var c=ele.getElementsByTagName("img"); for(var i=0;i<c.length;i++){ var w0=c[i].clientWidth,h0=c[i].clientHeight; var t1=w0/w,t2=h0/h; if(t1>1||t2>1){ c[i].width=Math.floor(w0/(t1>t2?t1