您好,欢迎访问三七文档
.Word资料精典代码讲解1.简单的跳转网页代码假如你要让页面显示3秒钟之后跳转,可以在html代码的head/head部分加上这样的代码:metahttp-equiv=refreshcontent=3;url=.yalandao.2.滚动字幕代码marqueewidth=200height=100direction=upscrollamount=3学电脑,买电脑;当然选择咱蓝岛!/marquee字幕方向:上下左右——up/down/left/rightalign:是设定活动字幕的位置,不过除了居左、居中、居右三种位置外,又增加靠上(align=top)和靠下(align=bottom)两种位置。Bgcolor:用于设定活动字幕的背景颜色,一般是十六进制数。Direction:用于设定活动字幕的滚动方向是向左、向右、向上、向下。Behavior:用于设定滚动的方式,主要由三种方式:behavior=scroll表示由一端滚动到另一端;behavior=slide:表示由一端快速滑动到另一端,且不再重复;behavior=alternate表示在两端之间来回滚动。Height:用于设定滚动字幕的高度。Width:则设定滚动字幕的宽度。Hspace和vspace:分别用于设定滚动字幕的左右边框和上下边框的宽度。Scrollamount:用于设定活动字幕的滚动距离。scrolldelay:用于设定滚动两次之间的延迟时间。Loop:用于设定滚动的次数,当loop=-1表示一直滚动下去,直到页面更新。标记的默认情况是向左滚动无限次,字幕高度是文本高度,滚动围:水平滚动的宽度是当前位置的宽度;垂直滚动的高度是当前位置的高度。.Word资料5.添加到收藏夹和设为首页ahref=#onclick=this.style.behavior='url(#default#homepage)';this.setHomePage('.yalandao.');设为首页/aahref=javascript:window.external.AddFavorite('.yalandao./',蓝岛电脑')收藏本站/a例如:输入代码ahref=javascript:window.external.AddFavorite('.yalandao./','蓝岛电脑')收藏本站/a ahref=#onclick=this.style.behavior='url(#default#homepage)';this.setHomePage('.yalandao.');设为首页/a/tr6.html网页时间显示代码和倒计时代码SCRIPTlanguage=JavaScriptvarenabled=0;today=newDate();varday;vardate;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=fontsize=5face=宋体color=0000ff+(today.getYear())+年+(today.getMonth()+1)+月+today.getDate()+日+/font;date2=fontsize=5face=宋体color=ff0000+day+/font;document.write(center+date1.fontsize(2)+date2.fontsize(2)+/center);.Word资料/SCRIPTPclass=t_msgfontalign=centerBRSPANid=liveclock15px?height:109px;style?=width:FONTcolor=#ff0f00size=517:47:26/FONT/SPANSCRIPTlanguage=javascriptfunction_helpor_net(){varDigital=newDate()varhours=Digital.getHours()varminutes=Digital.getMinutes()varseconds=Digital.getSeconds()if(minutes=9)minutes=0+minutesif(seconds=9)seconds=0+secondsmyclock=fontsize=5color=0000ff+hours+:+minutes+:+seconds+/fontif(document.layers){document.layers.liveclock.document.write(myclock)document.layers.liveclock.document.close()}elseif(document.all)liveclock.innerHTML=myclocksetTimeout(_helpor_net(),1000)}_helpor_net();//--/SCRIPT7.浏览器状态栏显示的时钟BODYonLoad=run();timerONE=window.setTimeout/BODYSCRIPTLANGUAGE=javascript!--HidetimeID=null;timeRunning=false;functionstop(){if(timeRunning)clearTimeout(timeID);timeRunning=false;}functiontime(){tick=newDate();hours=tick.getHours();minutes=tick.getMinutes();seconds=tick.getSeconds();.Word资料day=tick.getDay();month=tick.getMonth();date=tick.getDate();year=tick.getYear();current=+((hours12)?hours-12:hours)current+=((minutes10)?:0::)+minutescurrent+=((seconds10)?:0::)+secondscurrent+=(hours=12)?P.M.:A.M.if(day==0){varweekday=星期日}if(day==1){varweekday=星期一}if(day==2){varweekday=星期二}if(day==3){varweekday=星期三}if(day==4){varweekday=星期四}if(day==5){varweekday=星期五}if(day==6){varweekday=星期六}current+=(weekday)window.status=current;timeID=setTimeout(time(),1000);timeRunning=true;}functionrun(){stop();time();}//--/SCRIPT8.实时倒计时代码,可以设定期限!!--单位:秒--剩余时间:spanid=endtime10/spanscripttype=text/javascriptvarCID=endtime;if(window.CID!=null){variTime=document.getElementById(CID).innerText;varAccount;RemainTime();}functionRemainTime(){.Word资料variDay,iHour,iMinute,iSecond;varsDay=,sHour=,sMinute=,sSecond=,sTime=;if(iTime=0){iDay=parseInt(iTime/24/3600);if(iDay0){sDay=iDay+天;}iHour=parseInt((iTime/3600)%24);if(iHour0){sHour=iHour+小时;}iMinute=parseInt((iTime/60)%60);if(iMinute0){sMinute=iMinute+分钟;}iSecond=parseInt(iTime%60);if(iSecond=0){sSecond=iSecond+秒;}if((sDay==)&&(sHour==)){sTime=spanstyle='color:darkorange'+sMinute+sSecond+/font;}else{sTime=sDay+sHour+sMinute+sSecond;}if(iTime==0){clearTimeout(Account);sTime=spanstyle='color:green'时间到了!/span;}else{Account=setTimeout(RemainTime(),1000);}iTime=iTime-1;}else{sTime=spanstyle='color:red'倒计时结束!/span;}document.getElementById(CID).innerHTML=sTime;}.Word资料/script/body/html9.形如今天是2011年4月17日,星期三的代码scriptvarmydate=newDate()varyear=mydate.getYear()if(year1000)year+=1900varday=mydate.getDay()varmonth=mydate.getMonth()vardaym=mydate.getDate()if(daym10)daym=0+daymvardayarray=newArray(星期天,星期一,星期二,星期三,星期四,星期五,星期六)varmontharray=newArray(1,2,3,4,5,6,7,8,9,10,11,12)document.write(今天是+year+年+montharray[month]+月+daym+日+,+dayarray[day])/script10.根据不同的时间显示不同的问候语方法:在主页中你需要的地方加入以下代码:scriptlanguage=LiveScriptnow=newDate(),hour=now.getHours()if(hour6){document.write(明天不用上班了吗?)}elseif(hour8){document.write(全新的一天!)}elseif(hour12){document.write(早安!)}elseif(hour14){document.write(外面太阳大吗?)}elseif(hour18){document.write(午安!)}elseif(hour22){document.write(晚上好!)}elseif(hour24){document.write(夜深了!要注意身体呀!祝你做个好梦!)}//--/script说明,可以自行修改出更好更多的问候语!.Word资料显示最后更新时间代码SCRIPTlanguage=javascript!--hidescriptfromoldbrowsersdocument.write(最后更新时间:+document.lastModified+)//
本文标题:DW中代码实用手册
链接地址:https://www.777doc.com/doc-5008451 .html