首页 > 代码库 > JavaScript特效源码(8、其他特效)

JavaScript特效源码(8、其他特效)

1、中文日期

  中文日期[无须修改][共1步]]====1、将以下代码加入HEML的<body></body>之间<script LANGUAGE="JavaScript">function number(index1){var numberstring="一二三四五六七八九十";if(index1 ==0) {document.write("十")}if(index1 < 10){document.write(numberstring.substring(0+(index1-1),index1))}else if(index1 < 20 ){document.write("十"+numberstring.substring(0+(index1-11),(index1-10)))}else if(index1 < 30 ){document.write("二十"+numberstring.substring(0+(index1-21),(index1-20)))}else{document.write("三十"+numberstring.substring(0+(index1-31),(index1-30)))}}var today1 = new Date()var month = today1.getMonth()+1var date = today1.getDate()var day = today1.getDay()document.write("<br><strong><small><center>")document.write("公元二零零零年")number(month)document.write("月")number(date)document.write("日</small><center>")</script>  

 2、现在的日期及时间

  现在的日期及星期[无须修改][共1步]====1、将以下代码加入HEML的<body></body>之间<script language=JavaScript>today=new Date();function initArray(){this.length=initArray.arguments.lengthfor(var i=0;i<this.length;i++)this[i+1]=initArray.arguments[i] }var d=new initArray("星期日","星期一","星期二","星期三","星期四","星期五","星期六");document.write("<font color=##000000 style=‘font-size:9pt;font-family: 宋体‘> ",today.getYear(),"年",today.getMonth()+1,"月",today.getDate(),"日",d[today.getDay()+1],"</font>" ); </script> 

 3、带连接的滚动字幕

  带链接的滚动字幕[修改名称及链接][共1步]====1、将以下代码加入HEML的<body></body>之间<script language="JavaScript1.2">//设置marquee的宽度 (in pixels)var marqueewidth=400//设置marquee的高度 (in pixels, 该参数只适用于NS)var marqueeheight=20//设置marquee滚动的速度(数值大速度快)var speed=4//设置marquee显示内容,使用标准的HTML语法。var marqueecontents=‘<strong><big>欢迎访问 <a href="http://www.happydrips.com">快乐点滴</a> 欢迎您光临 <a href="mailto:yshot@263.net">给我来封信!</a></big></strong></font>‘if (document.all)document.write(‘<marquee scrollAmount=‘+speed+‘ style="width:‘+marqueewidth+‘">‘+marqueecontents+‘</marquee>‘)function regenerate(){window.location.reload()}function regenerate2(){if (document.layers){setTimeout("window.onresize=regenerate",450)intializemarquee()}}function intializemarquee(){document.cmarquee01.document.cmarquee02.document.write(‘<nobr>‘+marqueecontents+‘</nobr>‘)document.cmarquee01.document.cmarquee02.document.close()thelength=document.cmarquee01.document.cmarquee02.document.widthscrollit()}function scrollit(){if (document.cmarquee01.document.cmarquee02.left>=thelength*(-1)){document.cmarquee01.document.cmarquee02.left-=speedsetTimeout("scrollit()",100)}else{document.cmarquee01.document.cmarquee02.left=marqueewidthscrollit()}}window.onload=regenerate2</script><ilayer width=&{marqueewidth}; height=&{marqueeheight}; name="cmarquee01"> <layer name="cmarquee02"></layer></ilayer>  

 4、垂直滚动公告版

  垂直滚动公告板[修改显示的文字][共2步]====1、将下列代码加入HEML的<head></head>之间:<script><!--lstart=200loop=truespeed=350 pr_step=5 function makeObj(obj,nest){nest=(!nest) ? ‘‘:‘document.‘+nest+‘.‘this.css=(document.layers) ? eval(nest+‘document.‘+obj):eval(obj+‘.style‘)this.scrollHeight=document.layers?this.css.document.height:eval(obj+‘.offsetHeight‘)this.up=goUpthis.obj = obj + "Object"eval(this.obj + "=this")return this}function goUp(speed){if(parseInt(this.css.top)>-this.scrollHeight){this.css.top=parseInt(this.css.top)-pr_stepsetTimeout(this.obj+".up("+speed+")",speed)}else if(loop) {this.css.top=lstarteval(this.obj+".up("+speed+")")}}function slideInit(){oSlide=makeObj(‘divNews‘,‘divCont‘)oSlide.css.top=lstartoSlide.up(speed)}onload=slideInit//--></script>====2、将下列代码加入HEML的<body></body>之间:<div id="divCont"style="position:absolute; width:300; height:100; top:120; left:280; clip:rect(0,250,150,0)"><divid="divNews" style="position:absolute; top:0; left:0"><p>这是一个滚动看板<br>但并不是大家经常看到的<br>用<font face="Arial">java</font>实现的那种<br>它采用<font face="Arial">javacript</font>语言和<font face="Arial">DHTML</font>的层<br>所以你看到的原代码<br>不需要固定在form框里或者表格里<br>它是用的<font face="Arial"><div></div></font><br>你可以把这段代码放在<font face="Arial">HTML<br></font>代码里的任何地方<br>都不会影响它出现的位置</p><p>这是一个用处很大的程序<br>可以用在网页里作广告或则告示板<br>赶快<font face="Arial">Copy</font>到你的主页里试试吧!</p></div></div>  

 5、关闭窗口

关闭窗体[无须修改][共1步]====1、将以下代码加入HEML的<body></body>之间:<script language="JavaScript">function shutwin(){window.close();return;}</script><a href="javascript:shutwin();">关闭本窗口</a> 

 6、MIDI播放器

十分棒的MIDI播放器[共2步](可根据相应的项目修改)====1、将以下代码加入HTML的<head></head>之间:<Script Language="JavaScript"><!-- Hidingsong = new Array()var x = 0song[1] = "007主题曲之一"song[2] = "007主题曲之二"song[3] = "999朵玫瑰"song[4] = "X-档案主题曲"song[5] = "用心良苦"song[6] = "泰坦尼克主题曲"function prev(){if (x>1){ x--document.midi.typein.value=http://www.mamicode.com/song [x]"选曲"}// Done Hiding --></Script>====2、将以下代码加入HTML的<body></body>之间区:<BODY onl oad="cls()"><FORM Name="midi"><INPUT NAME="typein" TYPE="text" SIZE="25" ALIGN=top><BR><font size=3> <INPUT TYPE=Button Value="http://www.mamicode.com/|<<" Align=left onclick="start()"><INPUT TYPE=Button Value="http://www.mamicode.com/<<" Align=left onclick="prev()"><input type=Button value="http://www.mamicode.com/PLAY" align=left onClick="go()" name="Button"><INPUT TYPE=Button Value="http://www.mamicode.com/>>" Align=left onclick="next()"><INPUT TYPE=Button Value="http://www.mamicode.com/>>|" Align=left onclick="end()"></font></FORM> 

 7、问候语

分时问候[修改显示的文字][共1步]====1、将以下代码加入HTML 的<body></body>之间:<script language="javaScript"><!--now = new Date(),hour = now.getHours()if(hour < 6){document.write("凌晨好!")}else if (hour < 9){document.write("早上好!")}else if (hour < 12){document.write("上午好!")}else if (hour < 14){document.write("中午好!")}else if (hour < 17){document.write("下午好!")}else if (hour < 19){document.write("傍晚好!")}else if (hour < 22){document.write("晚上好!")}else {document.write("夜里好!")}// --></script> 

 8、密码保护页面

  密码保护页面[修改口令][共1步]1、将以下代码加入HEML的<body></body>之间:<script LANGUAGE="JAVASCRIPT"><!--loopy()function loopy() {var sWord =""while (sWord != "login") { //改为你自己的密码!sWord = prompt("输入正确密码才能登陆!本页密码:login")}alert("AH...欢迎光临!")}//--></script>   

 9、当前时间

  当前的时间[无须修改][共1步]====1、将以下代码加入HEML的<body></body>之间:<script language=JavaScript>var timerID = null;var timerRunning = false;function stopclock (){if(timerRunning)clearTimeout(timerID);timerRunning = false;}function startclock () {stopclock();showtime();}function showtime () {var now = new Date();var hours = now.getHours();var minutes = now.getMinutes();var seconds = now.getSeconds()var timeValuehttp://www.mamicode.com/= "" +((hours >= 12) ? "下午 " : "上午 " )timeValue += ((hours >12) ? hours -12 :hours)timeValue += ((minutes < 10) ? ":0" : ":") + minutestimeValue += ((seconds < 10) ? ":0" : ":") + secondsdocument.clock.thetime.value = http://www.mamicode.com/timeValue;"showtime()",1000);timerRunning = true;}</SCRIPT><body onl oad=startclock()><form name=clock ><input name=thetime style="font-size: 9pt;color:#000000;border:0" size=12></form></body>