![]() |
|
JAVASCRIPT速成秘诀
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
广告招租,e-mail:yesize@hotmail.com 通过了解下面的一些例子,并运用到你的WEB中,不久你马上成为JAVASCIPT的高手。 例(一)、在页面加入当前时间 〈 script language=JavaScript > tdy=new Date(); document.write(当前时间:,tdy.getHours()); document.write(:,tdy.getMinutes()); document.write(:,tdy.getSeconds()); 〈/script > 例(二)、在页面加入文档最后修改日期 〈 script language=JavaScript > document.write(本页最后编辑日期:); document.write(document.lastModified) 〈/script > 例(三)、在窗口的状态提示窗显示移动信息 (1) 在BODY之前 〈 script language=JavaScript > var msg=这是一个状态行滚动显示的JAVASCIPT程序,有兴趣的同志,可以粘贴!; var i=1 function scroll() { mess=msg.substring(i,msg.length)+ +msg.substring(0,i) window.status=mess i++; if (i>=msg.length) i=1; setTimeout(scroll(),200); } 〈/script > (2)在BODY标签中: 〈body onload=scroll() > 通过以上两步即可完成。 例(四)、提供前进、后退功能 〈 form > 〈 input type=button value=〈- onclick=history.go(-1) > 〈 input type=button value=-> onclick=history.go(1) > 〈 /form > 例(五)、在页面加入文档最后修改日期 〈 script language=JavaScript > document.write(本页最后编辑日期:); document.write(document.lastModified) 〈/script > 例(六)、鼠标移到时发生动作 〈 A HREF=MAILTO:ZZY71616@163.NET onmouseover=alert(写信给我); return true > 信箱〈 /A > 例(七)、提供前进、后退功能 〈 H3 onclick=history.go(-1) > 前一页〈 /H3> 〈 H3 onclick=history.go(-2) > 前两页〈 /H3> 〈 H3 onclick=history.go(-3) > 前三页〈 /H3> 〈 H3 onclick=history.go(1) > 后一页〈 /H3> 〈 H3 onclick=history.go(2) > 后两页〈 /H3> 〈 H3 onclick=history.go(3) > 后三页〈 /H3> 例(八)、获得浏览器的属性 navigator.appCodename=undefinednavigator.appName=Microsoft Internet Explorernavigator.appVersion=4.0 (compatible; MSIE 5.0; Windows 98; DigExt)navigator.appAgent=undefined
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||