网页常用javascript 获取当前时间 常见的特效 节日倒计时

合集下载

JavaScript实现前端网页版倒计时

JavaScript实现前端网页版倒计时

JavaScript实现前端⽹页版倒计时使⽤原⽣JavaScript简单实现倒计时,供⼤家参考,具体内容如下效果代码// An highlighted block<!DOCTYPE html><html><head><meta charset="utf-8"><title></title><!-- css样式 --><style type="text/css">* {margin: 0;padding: 0;}.onsell {height: 400px;width: 200px;border: 1px solid #F2F2F2;margin: 10px;box-shadow: 1px 2px 4px rgba(0, 0, 0, .2);}.box {/* display: none; */float: left;margin: 328px 34px 0;}.box div {position: relative;display: inline-block;width: 40px;height: 40px;background-color: #333;color: #fff;font-size: 20px;text-align: center;line-height: 40px;box-shadow: 1px 2px 4px rgba(0, 0, 0, .4);}</style></head><body><!-- 要求:某商品在将来某⼀天进⾏促销⼀天,利⽤js制作倒计时效果:时:分:秒 --><div class="onsell"><div class="box"><div class="hour">00</div><div class="minutes">00</div><div class="seconds">00</div></div></div></body></html><script>window.onload = function () {let hour = document.querySelector('.hour')let minutes = document.querySelector('.minutes')let seconds = document.querySelector('.seconds')// 倒计时的时间戳使⽤+将时间对象转为时间戳等同于Date.now()let wantTime = +new Date('2021-3-17 18:00:00')countTime()let timer = setInterval(() => {countTime()}, 1000)function countTime() {let currentTime = +new Date()if (wantTime >= currentTime) {let times = (wantTime - currentTime) / 1000 // 总秒数时间戳/1000 = 秒let remainDay = parseInt(times / 60 / 60 / 24) // 余数取整就是剩余的天数console.log(remainDay);if (remainDay === 0) {if(times < 1) {// 倒计时完毕// 这⾥触发操作}// 天数⼩于⼀天开始计时setTime(times)}} else {hour.innerHTML = '00'minutes.innerHTML = '00'seconds.innerHTML = '00'}}function setTime(time) {// 粗糙版let s = parseInt(time % 60)s = s < 10 ? '0' + s : slet m = parseInt(time / 60 % 60)m = m < 10 ? '0' + m : mlet h = parseInt(time / 60 / 60 % 24)h = h < 10 ? '0' + h : hhour.innerHTML = hminutes.innerHTML = mseconds.innerHTML = s}}</script>以上就是本⽂的全部内容,希望对⼤家的学习有所帮助,也希望⼤家多多⽀持。

javascript实现倒计时并弹窗提示特效

javascript实现倒计时并弹窗提示特效

javascript实现倒计时并弹窗提⽰特效在前端开发中,难免会⽤到倒计时。

如做的双⼗⼀活动,在距活动开始的半个⽉前需要做些宣传⼯作,需要告知⽤户优惠活动什么时候开始。

这个时候就要⽤到倒计时,如在整站的某个页⾯提醒⽤户活动什么时候开始等。

⽽在活动的后期,特别是在距活动结束仅有1天左右时,就要⽤到弹窗倒计时。

这个倒计时设置在整站的⾸页顶部(当然也可以设置在其它地⽅,如⾸页中部等),并设置弹窗弹出10秒后⾃动消失,由⽤户决定是否点击到相应的活动页⾯,购买产品。

需要的技术⽀持:CSS3,jQuery库;HTML代码如下:<section class="the_body"><div class="countdown"><h3>距中国雄于地球之⽇还有</h3><div class="countdown_time"><span class="the_days"><i>0</i><i>3</i></span><i class="date_text">天</i><span class="the_hours"><i>0</i><i>7</i></span><i class="date_text">时</i><span class="the_minutes"><i>4</i><i>7</i></span><i class="date_text">分</i><span class="the_seconds"><i>1</i><i>1</i></span><i class="date_text">秒</i></div></div></section>css代码如下:.the_body{width: 100%;max-width: 640px;min-width: 320px;margin: 0 auto;}.countdown{background:#ffec20;padding: 10px 0;}.countdown h3{margin:0;padding:5px 0;color:#f53544;text-align:center;font-size:14px;}.countdown .countdown_time{display:block;width:100%;text-align:center;}.countdown .countdown_time i{display:inline-block;position:relative;padding:0 3px;font-style:normal;background:#fff;margin:0 2px;border-radius:3px;box-shadow:0px 1px 1px #ccc;border-bottom:1px solid #cfcfcf;font-weight:bold;}.countdown .countdown_time i:after{content:"";width:100%;border:1px solid #cfcfcf;border-width:1px 0 0;position:absolute;bottom:1px;left:0;}.countdown .countdown_time i:before{content:"";width:100%;border:1px solid #cfcfcf;border-width:1px 0 0;position:absolute;bottom:3px;left:0;}.countdown .countdown_time .date_text{background:transparent;font-weight:bold;box-shadow:none;border-bottom:none;text-decoration:none;padding: 0;}.countdown .countdown_time .date_text:after{content:"";border:none;}.countdown .countdown_time .date_text:before{content:"";border:none;}JavaScript代码如下:<script>function remaintime() {var date = new Date("Jan 1,2015 00:00:00");//设置倒计时结束时间var nowdate = new Date();//获取当前⽇期var remaintime = date.getTime() - nowdate.getTime();//获取现在到倒计时结束时间的毫秒数var remainday = Math.floor(remaintime / (1000 * 60 * 60 * 24));//计算求得剩余天数var remainhour = Math.floor((remaintime - remainday * 1000 * 60* 60 * 24)/ (1000 * 60 * 60));//计算求得剩余⼩时数var remainminute = Math.floor((remaintime - remainday * 1000 * 60* 60 * 24 - remainhour * 1000 * 60 * 60)/ (1000 * 60));//计算求得剩余分钟数var remainsecond = Math.floor((remaintime - remainday * 1000 * 60 * 60 * 24- remainhour * 1000 * 60 * 60 - remainminute *1000 * 60) / (1000));//计算求得剩余秒数//当剩余天数⼩于10时,就在其前加⼀个0,以下剩余⼩时数、分钟数与秒数与此相同if (remainday < 10) {remainday = "0" + remainday;}else{remainday+="";//当剩余天数⼤于10时,剩余天数为数值,这是需要将该值转换为字符串,以下的剩余⼩时数、分钟数与秒数与此相同}if (remainhour < 10) {remainhour = "0" + remainhour;}else{remainhour+="";}if (remainminute < 10) {remainminute = "0" + remainminute;}else{remainminute+="";}if (remainsecond < 10) {remainsecond = "0" + remainsecond;}else{remainsecond+="";}$(".the_days i:first-child").html(remainday.substr(0, 1));$(".the_days i:last-child").html(remainday.substr(1, 2));$(".the_hours i:first-child").html(remainhour.substr(0, 1));$(".the_hours i:last-child").html(remainhour.substr(1, 2));$(".the_minutes i:first-child").html(remainminute.substr(0, 1));$(".the_minutes i:last-child").html(remainminute.substr(1, 2));$(".the_seconds i:first-child").html(remainsecond.substr(0, 1));$(".the_seconds i:last-child").html(remainsecond.substr(1, 2));setTimeout("remaintime()",1000);//设置1秒后调⽤remaintime函数}remaintime();setTimeout(function(){$(".countdown").hide();},10000);//在⾸页设置的弹窗效果,在分页这段代码可以不设置</script>这是我⾃⼰写的倒计时效果,当然每个⼈都可以根据⾃⼰的爱好,设置倒计时的效果。

网页常用javascript 获取当前时间 常见的特效 节日倒计时

网页常用javascript 获取当前时间 常见的特效 节日倒计时

一些比较简单的javascript:function get_time() /**获取当前时间**/{var date=new Date();var year="",month="",day="",week="",hour="",minute="",second=""; year=date.getYear();month=add_zero(date.getMonth()+1);day=add_zero(date.getDate());week=date.getDay();switch (date.getDay()) {case 0:val="星期天";breakcase 1:val="星期一";breakcase 2:val="星期二";breakcase 3:val="星期三";breakcase 4:val="星期四";breakcase 5:val="星期五";breakcase 6:val="星期六";break}hour=add_zero(date.getHours());minute=add_zero(date.getMinutes());second=add_zero(date.getSeconds());timetable.innerText=" "+year+"年"+month+"月"+day+"日"+hour+":"+minute+":"+second+" "+val;}1.让文字不停地滚动<MARQUEE>滚动文字</MARQUEE>2.记录并显示网页的最后修改时间<script language=Javascript>document.write("最后更新时间: " + stModified + "")</script>3.关闭当前窗口<a href="/"onClick="javascript:window.close();return false;">关闭窗口</a>4.5秒后关闭当前页<script language="Javascript"><!--setTimeout('window.close();',5000);--></script>5.2秒后载入指定网页<head><meta http-equiv="refresh" content="2;URL=http://你的网址"></head>6.添加到收藏夹<script Language="Javascript">function bookmarkit(){window.external.addFavorite('http://你的网址','你的网站名称')}if (document.all)document.write('<a href="#" onClick="bookmarkit()">加入收藏夹</a>')</script>7.让超链接不显示下划线<style type="text/css"><!-a:link{text-decoration:none}a:hover{text-decoration:none}a:visited{text-decoration:none}-></style>8.禁止鼠标右键的动作<script Language = "Javascript">function click() { if (event.button==2||event.button==3){alert('禁止鼠标右键');}document.onmousedown=click // --></script>9.设置该页为首页<body bgcolor="#FFFFFF" text="#000000"><!-- 网址:http://你的网址--><a class="chlnk" style="cursor:hand" HREFonClick="this.style.behavior='url(#default#homepage)';this.setHomePage('你的网站名称);"><font color="000000" size="2" face="宋体">设为首页</font></a></body>10.节日倒计时<script Language="Javascript">var timedate= new Date("December 25,2003");var times="圣诞节";var now = new Date();var date = timedate.getTime() - now.getTime();var time = Math.floor(date / (1000 * 60 * 60 * 24));if (time >= 0)document.write("现在离"+times+"还有: "+time +"天")</script>11.单击按钮打印出当前页<script Language="Javascript"><!-- Beginif (window.print) {document.write('<form>'+ '<input type=button name=print value="打印本页" '+ 'onClick="javascript:window.print()"></form>');}// End --></script>12.单击按钮‘另存为’当前页<input type="button" name="Button" value="保存本页"onClick="document.all.button.ExecWB(4,1)"><object id="button"width=0height=0classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"><embed width="0" height="0"></embed></object>13.显示系统当前日期<script language=Javascript>today=new Date();function date(){this.length=date.arguments.lengthfor(var i=0;i<this.length;i++)this[i+1]=date.arguments }var d=new date("星期日","星期一","星期二","星期三","星期四","星期五","星期六");document.write("<font color=##000000 style='font-size:9pt;font-family: 宋体'> ", today.getYear(),"年",today.getMonth()+1,"月",today.getDate(),"日", d[today.getDay()+1],"</font>" );</script>14.不同时间段显示不同问候语<script Language="Javascript"><!--var text=""; day = new Date( ); time = day.getHours( );if (( time>=0) && (time < 7 ))text="夜猫子,要注意身体哦! "if (( time >= 7 ) && (time < 12))text="今天天气……哈哈哈,不去玩吗?"if (( time >= 12) && (time < 14))text="午休时间哦,朋友一定是不习惯午睡的吧?!"if (( time >=14) && (time < 18))text="下午茶的时间到了,休息一下吧! "if ((time >= 18) && (time <= 22))text="您又来了,可别和MM聊太久哦!"if ((time >= 22) && (time < 24))text="很晚了哦,注意休息呀!"document.write(text)//---></script>15.水中倒影效果<img id="reflect" src="你自己的图片文件名" width="175" height="59"><script language="Javascript">function f1(){setInterval("mdiv.filters.wave.phase+=10",100);}if (document.all)document.write('<img id=mdiv src="'+document.all.reflect.src+'" style="filter:wave(strength=3,freq=3,phase=0,lightstrength=30) blur() flipv()">')window.onload=f1}</script>16.慢慢变大的窗口<script Language="Javascript"><!--var Windowsheight=100var Windowswidth=100var numx=5function openwindow(thelocation){temploc=thelocationif(!(window.resizeTo&&document.all)&&!(window.resizeTo&&document.getEle mentById)){window.open(thelocation)return}windowsize=window.open("","","scrollbars")windowsize.moveTo(0,0)windowsize.resizeTo(100,100)tenumxt()}function tenumxt(){if (Windowsheight>=screen.availHeight-3)numx=0windowsize.resizeBy(5,numx)Windowsheight+=5Windowswidth+=5if (Windowswidth>=screen.width-5){windowsize.location=templocWindowsheight=100Windowswidth=100numx=5return}setTimeout("tenumxt()",50)//--></script><p><a href="javascript:openwindow(/smile%5F%B1%B4)">进入</a>17.改变IE地址栏的IE图标我们要先做一个16*16的icon(图标文件),保存为index.ico。

js获取当前指定的前几天的日期(如当前时间的前七天的日期),倒计时

js获取当前指定的前几天的日期(如当前时间的前七天的日期),倒计时

js获取当前指定的前⼏天的⽇期(如当前时间的前七天的⽇期),倒计时⼀、js获取当前时间。

格式为2016-03-23.var d = new Date(),mon = parseInt(d.getMonth()+1),str = "";if(mon<10){str = d.getFullYear()+"-0"+(d.getMonth()+1)+"-"+d.getDate();}else{str = d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();}console.log(str)获取当前时间,特定时间前的⽇期//⽇期时间计算function getBeforeDate(n) {var n = n;var d = new Date();var year = d.getFullYear();var mon = d.getMonth() + 1;var day = d.getDate();if(day <= n) {if(mon > 1) {mon = mon - 1;} else {year = year - 1;mon = 12;}}d.setDate(d.getDate() - n);year = d.getFullYear();mon = d.getMonth() + 1;day = d.getDate();s = year + "-" + (mon < 10 ? ('0' + mon) : mon) + "-" + (day < 10 ? ('0' + day) : day);return s;}console.log(getBeforeDate(1));//昨天的⽇期console.log(getBeforeDate(7));//前七天的⽇期 ⼆、倒计时 商品类⽹站,经常会有限时特卖这类产品,经常会有⼀个倒计时。

js倒计时功能,获取当前时间的年月日,时分秒

js倒计时功能,获取当前时间的年月日,时分秒

js倒计时功能,获取当前时间的年⽉⽇,时分秒⼀、实现当前时间到指定截⽌时间的倒计时功能<html><head><title>TEST</title></head><body><script>//获取当前时间距离截⽌时间的倒计时//参数为截⽌时间var leftTimer = function(year, month, day, hour, minute, second){var leftTime = (new Date(year, month-1, day, hour, minute, second)) - (new Date());//计算剩余毫秒数var days = parseInt(leftTime / 1000 / 60 / 60 / 24, 10);//计算剩余天数var hours = parseInt(leftTime / 1000 / 60 / 60 % 24, 10);//计算剩余⼩时数var minutes = parseInt(leftTime / 1000 / 60 % 60, 10);//计算剩分钟数var seconds = parseInt(leftTime / 1000 % 60, 10);//计算剩余秒数days = checkTime(days).toString();hours = checkTime(hours).toString();minutes = checkTime(minutes).toString();seconds = checkTime(seconds).toString();return days + ' : ' + hours + ' : ' + minutes + ' : ' + seconds}var checkTime = function(i){if(i < 10){i = "0" + i;}return i;}setInterval(function() {document.getElementById('testId').innerHTML = leftTimer(2018, 12, 31, 11, 0, 0)}, 1000)</script><div id="testId"> </div></body></html>⼆、获取当前的年⽉⽇时分秒var currTime = new Date(); //获取当前时间的毫秒数var year = currTime.getFullYear(); //获取当前时间的年份var month = currTime.getMonth() + 1; //获取当前时间的⽉份,⽉份从0开始,所以需要加⼀var day = currTime.getDate(); //获取当前时间的⽇期,getDay()可以获取星期⼏var hour = currTime.getHours(); //获取当前时间的⼩时数var minute = currTime.getMinutes(); //获取当前时间的分钟数var second = currTime.getSeconds(); //获取当前时间的秒数三、毫秒数转成年⽉⽇时分秒//毫秒数转换成时间var getCurrentTime = function(milliseconds){var myDate = new Date(milliseconds);var year = myDate.getFullYear();var month = myDate.getMonth() + 1;var day = myDate.getDate()var hour = myDate.getHours();var minute = myDate.getMinutes();var second = myDate.getSeconds();month = checkTime(month).toString();day = checkTime(day).toString();hour = checkTime(hour).toString();minute = checkTime(minute).toString();second = checkTime(second).toString();return year+"-"+month+"-"+day+" "+hour+":"+minute+":"+second; }// 只有⼀位数字时添加“0”var checkTime = function(i){if(i < 10){i = "0" + i;}return i;}。

js倒计时的2种方法

js倒计时的2种方法

js倒计时的2种⽅法第⼀种,简单时长倒计时data() {return {timer: null,m: 0,s: 0,time: null,}},created() {this.resetTime(125); //倒计时125S,根据⾃⼰的时长确定},methods: {//单纯分钟和秒倒计时resetTime(time){this.m = Math.floor(time / 60);this.m = this.m < 10 ? `0${this.m}` : this.m;console.log('this.m--',this.m);this.s = Math.floor(time % 60);this.timer = setInterval(this.countDown,1000);},countDown(){this.s--;this.s < 10 && (this.s = '0' + this.s);// this.s = this.s < 10 ? `0${this.s}` : this.s;if(this.s.length >= 3){this.s = 59;this.m = `0${(Number(this.m)-1)}`;}if(this.m.length >= 3){this.m='00';this.s='00';clearInterval(this.timer);}this.time = `${this.m}分钟${this.s}秒`;console.log(this.m+"分钟"+this.s+"秒");},}第⼆种,根据后端返回的时间戳,与当前时间进去⽐较,进⾏倒计时data() {return { timer: null,time: null,}},created() {this.timer = setInterval(this.countTime,1000);},methods: {countTime() {//获取当前时间let date = new Date();let now = date.getTime();//设置截⽌时间let str="2021/3/15 00:00:00";let endDate = new Date(str);let end = endDate.getTime();//时间差let leftTime = end - now;//定义变量 d,h,m,s保存倒计时的时间let d,h,m,s;if (leftTime >= 0) {d = Math.floor(leftTime/1000/60/60/24);h = Math.floor(leftTime/1000/60/60%24);m = Math.floor(leftTime/1000/60%60);s = Math.floor(leftTime/1000%60);}else { clearInterval(this.timer); //为负数时清掉定时器 }//递归每秒调⽤countTime⽅法,显⽰动态时间效果this.time = `${m}分${s}秒`; if(m == 0 && s == 0) { clearInterval(this.timer); //时间倒计完清掉计时器,并且跳转,这⾥根据⾃⼰的需求写就好了 this.$app.$redirect('/register/invallid',true); }},}。

网页显示时间代码和倒计时代码大全

网页显示时间代码和倒计时代码大全

网页显示时间代码和倒计时代码大全:<SCRIPT language=JavaScript>var enabled = 0; today = new Date();var day; var date;if(today.getDay()==0) day = "星期日"if(today.getDay()==1) day = "星期一"if(today.getDay()==2) day = "星期二"if(today.getDay()==3) day = "星期三"if(today.getDay()==4) day = "星期四"if(today.getDay()==5) day = "星期五"if(today.getDay()==6) day = "星期六"document.fgColor = " cadet";date1 = "<font size=5 face=宋体 color=0000ff>" + (today.getYear()) + "年" + (today.getMonth() + 1 ) + "月" + today.getDate() + "日 " + "</font>";date2 = "<font size=5 face=宋体 color=ff0000>" + day + "</font>";document.write("<center>" + date1.fontsize(2) + date2.fontsize(2) + "</center>");</SCRIPT><P class=t_msgfont align=center><BR><SPAN id=liveclock 15px? height: 109px; style?="width:"><FONT color=#ff0f00 size=5>17:47:26</FONT></SPAN><SCRIPT language=javascript>function www_helpor_net(){var Digital=new Date()var hours=Digital.getHours()var minutes=Digital.getMinutes()var seconds=Digital.getSeconds()if(minutes<=9)minutes="0"+minutesif(seconds<=9)seconds="0"+secondsmyclock="<font size=5 color=0000ff>"+hours+":"+minutes+":"+seconds+"</font>"if(yers){yers.liveclock.document.write(myclock) yers.liveclock.document.close()}else if(document.all)liveclock.innerHTML=myclocksetTimeout("www_helpor_net()",1000)}www_helpor_net();//--></SCRIPT>中文显示的时候保存为.js文件再用网页调用出现乱码。

JS实现倒计时功能(天,时,分,秒),以及当天倒计时

JS实现倒计时功能(天,时,分,秒),以及当天倒计时

JS实现倒计时功能(天,时,分,秒),以及当天倒计时1.给定任意⼀个时间,然后实现现在到那个时间的倒计时。

下⾯的例⼦是显⽰现在到2021年1⽉1号0时0分的倒计时:function showTime() {//获取⽬的⽇期var myyear = 2021; //年var mymonth = 12 - 1; //⽉只需要填写 - 前⾯的数字,这⾥是⼗⼆⽉var myday = 0; //天var myhour = 00; //时var myminute = 00; //分var mysecond = 00; //秒//以上综合填⼊的时间是 2021年12⽉1号0时0分;var time = Number(new Date(myyear, mymonth, myday, myhour, myminute, mysecond));// var time=new Date(myyear,mymonth,myday,myhour,myminute,mysecond).getTime();//获取当前时间var nowTime = Date.now();// var nowTime = new Date().getTime();//获取时间差var timediff = Math.round((time - nowTime) / 1000);//获取还剩多少天var day = parseInt(timediff / 3600 / 24);//获取还剩多少⼩时var hour = parseInt(timediff / 3600 % 24);//获取还剩多少分钟var minute = parseInt(timediff / 60 % 60);//获取还剩多少秒var second = timediff % 60;//输出还剩多少时间console.log(timerFilter(day)+"天"+timerFilter(hour)+"时"+timerFilter(minute)+"分"+timerFilter(second)+"秒")setTimeout(showTime, 1000);//给⼩于10的数值前⾯加 0function timerFilter(params) {if (params - 0 < 10) {return '0' + params} else {return params}}}2.当前时间到当天23:59:59倒计时。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

一些比较简单的javascript:function get_time() /**获取当前时间**/{var date=new Date();var year="",month="",day="",week="",hour="",minute="",second=""; year=date.getYear();month=add_zero(date.getMonth()+1);day=add_zero(date.getDate());week=date.getDay();switch (date.getDay()) {case 0:val="星期天";breakcase 1:val="星期一";breakcase 2:val="星期二";breakcase 3:val="星期三";breakcase 4:val="星期四";breakcase 5:val="星期五";breakcase 6:val="星期六";break}hour=add_zero(date.getHours());minute=add_zero(date.getMinutes());second=add_zero(date.getSeconds());timetable.innerText=" "+year+"年"+month+"月"+day+"日"+hour+":"+minute+":"+second+" "+val;}1.让文字不停地滚动<MARQUEE>滚动文字</MARQUEE>2.记录并显示网页的最后修改时间<script language=Javascript>document.write("最后更新时间: " + stModified + "")</script>3.关闭当前窗口<a href="/"onClick="javascript:window.close();return false;">关闭窗口</a>4.5秒后关闭当前页<script language="Javascript"><!--setTimeout('window.close();',5000);--></script>5.2秒后载入指定网页<head><meta http-equiv="refresh" content="2;URL=http://你的网址"></head>6.添加到收藏夹<script Language="Javascript">function bookmarkit(){window.external.addFavorite('http://你的网址','你的网站名称')}if (document.all)document.write('<a href="#" onClick="bookmarkit()">加入收藏夹</a>')</script>7.让超链接不显示下划线<style type="text/css"><!-a:link{text-decoration:none}a:hover{text-decoration:none}a:visited{text-decoration:none}-></style>8.禁止鼠标右键的动作<script Language = "Javascript">function click() { if (event.button==2||event.button==3){alert('禁止鼠标右键');}document.onmousedown=click // --></script>9.设置该页为首页<body bgcolor="#FFFFFF" text="#000000"><!-- 网址:http://你的网址--><a class="chlnk" style="cursor:hand" HREFonClick="this.style.behavior='url(#default#homepage)';this.setHomePage('你的网站名称);"><font color="000000" size="2" face="宋体">设为首页</font></a></body>10.节日倒计时<script Language="Javascript">var timedate= new Date("December 25,2003");var times="圣诞节";var now = new Date();var date = timedate.getTime() - now.getTime();var time = Math.floor(date / (1000 * 60 * 60 * 24));if (time >= 0)document.write("现在离"+times+"还有: "+time +"天")</script>11.单击按钮打印出当前页<script Language="Javascript"><!-- Beginif (window.print) {document.write('<form>'+ '<input type=button name=print value="打印本页" '+ 'onClick="javascript:window.print()"></form>');}// End --></script>12.单击按钮‘另存为’当前页<input type="button" name="Button" value="保存本页"onClick="document.all.button.ExecWB(4,1)"><object id="button"width=0height=0classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"><embed width="0" height="0"></embed></object>13.显示系统当前日期<script language=Javascript>today=new Date();function date(){this.length=date.arguments.lengthfor(var i=0;i<this.length;i++)this[i+1]=date.arguments }var d=new date("星期日","星期一","星期二","星期三","星期四","星期五","星期六");document.write("<font color=##000000 style='font-size:9pt;font-family: 宋体'> ", today.getYear(),"年",today.getMonth()+1,"月",today.getDate(),"日", d[today.getDay()+1],"</font>" );</script>14.不同时间段显示不同问候语<script Language="Javascript"><!--var text=""; day = new Date( ); time = day.getHours( );if (( time>=0) && (time < 7 ))text="夜猫子,要注意身体哦! "if (( time >= 7 ) && (time < 12))text="今天天气……哈哈哈,不去玩吗?"if (( time >= 12) && (time < 14))text="午休时间哦,朋友一定是不习惯午睡的吧?!"if (( time >=14) && (time < 18))text="下午茶的时间到了,休息一下吧! "if ((time >= 18) && (time <= 22))text="您又来了,可别和MM聊太久哦!"if ((time >= 22) && (time < 24))text="很晚了哦,注意休息呀!"document.write(text)//---></script>15.水中倒影效果<img id="reflect" src="你自己的图片文件名" width="175" height="59"><script language="Javascript">function f1(){setInterval("mdiv.filters.wave.phase+=10",100);}if (document.all)document.write('<img id=mdiv src="'+document.all.reflect.src+'" style="filter:wave(strength=3,freq=3,phase=0,lightstrength=30) blur() flipv()">')window.onload=f1}</script>16.慢慢变大的窗口<script Language="Javascript"><!--var Windowsheight=100var Windowswidth=100var numx=5function openwindow(thelocation){temploc=thelocationif(!(window.resizeTo&&document.all)&&!(window.resizeTo&&document.getEle mentById)){window.open(thelocation)return}windowsize=window.open("","","scrollbars")windowsize.moveTo(0,0)windowsize.resizeTo(100,100)tenumxt()}function tenumxt(){if (Windowsheight>=screen.availHeight-3)numx=0windowsize.resizeBy(5,numx)Windowsheight+=5Windowswidth+=5if (Windowswidth>=screen.width-5){windowsize.location=templocWindowsheight=100Windowswidth=100numx=5return}setTimeout("tenumxt()",50)//--></script><p><a href="javascript:openwindow(/smile%5F%B1%B4)">进入</a>17.改变IE地址栏的IE图标我们要先做一个16*16的icon(图标文件),保存为index.ico。

相关文档
最新文档