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!