1 2 3 4 5 6 7 8 9 | <b><font color="blue">本站已运行<font color="red"> <script language=JavaScript> var urodz= new Date("02/01/2008"); var now = new Date(); var ile = now.getTime() - urodz.getTime(); var dni = Math.floor(ile / (1000 * 60 * 60 * 24)); document.write(+dni) </script> </font>天</font></b> |
标签归档:JS
网页上JS显示倒计时
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | <b><font color="blue">奥运会开幕还有:</font> <font color="red"><span id="timeDate">载入天数...</span><span id="times">载入秒数...</span> <script type="text/javascript"><!-- var now = new Date(); function createtime(){ var grt= new Date("8/08/2008 20:00:00"); now.setTime(now.getTime()+250); days = (grt - now) / 1000 / 60 / 60 / 24; dnum = Math.floor(days); hours = (grt - now) / 1000 / 60 / 60 - (24 * dnum); hnum = Math.floor(hours); if(String(hnum).length ==1 ){hnum = "0" + hnum;} minutes = (grt - now) / 1000 /60 - (24 * 60 * dnum) - (60 * hnum); mnum = Math.floor(minutes); if(String(mnum).length ==1 ){mnum = "0" + mnum;} seconds = (grt - now) / 1000 - (24 * 60 * 60 * dnum) - (60 * 60 * hnum) - (60 * mnum); snum = Math.round(seconds); if(String(snum).length ==1 ){snum = "0" + snum;} document.getElementById("timeDate").innerHTML = dnum+"天"; document.getElementById("times").innerHTML = hnum + ":" + mnum + ":" + snum; } setInterval("createtime()",250); // --></script> </font></b> |
用JS在你的网页上显示当前时间
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | <font color="red"><b> <script language="JavaScript"> <!-- tmpDate = new Date(); date = tmpDate.getDate(); month= tmpDate.getMonth() + 1 ; myyear= tmpDate.getYear(); year=(myyear > 200) ? myyear : 1900 + myyear; document.write(year); document.write("年"); document.write(month); document.write("月"); document.write(date); document.write("日 "); myArray=new Array(6); myArray[0]="星期日" myArray[1]="星期一" myArray[2]="星期二" myArray[3]="星期三" myArray[4]="星期四" myArray[5]="星期五" myArray[6]="星期六" weekday=tmpDate.getDay(); if (weekday==0 | weekday==6) { document.write(myArray[weekday]) } else {document.write(myArray[weekday]) }; hours = tmpDate.getHours(); minutes = tmpDate.getMinutes(); seconds = tmpDate.getSeconds(); times = "<font color=orange>" + ((hours >24) ? hours -12 :hours); times += ((minutes < 10) ? "<blink>:</blink>0" : "<blink>:</blink>") + minutes+"</font>"; times += (hours >= 12) ? "<b>PM</b>" : "<b>AM</b>"; document.write(times); // --> </script> </b></font> |
可拖拽的LOGO
一个网页链接的滑动效果
基于js和css,作者在其首页提供了DIY的工具。当鼠标经过链接的时候,有一个上下滑动的效果。
http://www.scrollovers.com
可以这样使用这个效果:
1、在网页中加入如下,可以把js下载下来,放到自己的空间里。
1 | <script src="http://www.scrollovers.com/js/scrollovers.js" type="text/javascript"></script> |
2、将链接形式修改成这样
1 | <a href="http://www.hicode.org/wp-admin/[YOUR PAGE HERE]" TYPE="scrollover" class="scrollover">[YOUR TEXT HERE]</a> |
3、添加这样的CSS,颜色自己修改。
1 2 3 4 | <style> a.scrollover { /* Default Colour/Styles here */ color: #557AFF; } a.scrollover em:first-line { /* Rollover Colour/Styles here */ color: #FF5B3C; } </style> |
4、还可以修改js,达到你想要的效果。
scrollovers_ScrollSpeed 是控制速度的
scrollovers_ScrollDownOnMouseOver 是控制上滚还是下滚的
scrollovers_TypeName 如果想所有的链接都滚动,而不需要设置Type attrbiute的话,把这个变量的值改成空字符
收藏自:Hi,Code!