首页 美女贴图 网络日记 重庆租房 搜索指南 网络电视 飘网音乐 飘网博客 精彩网址 友情链接 飘网地图 本站留言
飘网中国
专题:网络营销 | 网站设计 | QQ技巧 | 搜索优化 | 菜鸟进阶 | 病毒攻防 | 网络技术 | 系统应用 | 本站作品 | 常用软件 | 工具软件 |
飘网中国>>网站设计>>正文

入门教程:Javascript学习讲解(二)

编辑:Admin 来源:蓝色理想 更新:2007-9-5 点击:
【字体:

摘要:清华大学出版的《事半功倍系列 javascript》,本人照着书敲出来的,有些翻译了一下.前几年看了一下,最近无事,重新翻了翻,很有帮助.本书应该有光盘的,但学校的书,光盘不知在哪.希望对你学 javascript有帮助
关键字:Javascript学习 js 
正文:
document.write("字符串全部大写是;"+str1.toUpperCase())
document.write("字符串全部小写是;"+str1.toLowerCase())
</script>
7.在字符串内搜索

<script>
str1="this is the end of the line.<br>"
document.write(str1)
document.write("字符end在字符串的位置是"+str1.search("end"))
document.write("字符dog在字符串的位置是"+str1.search("dog"))
</script>
8.定位字符串中的字符

<script>
str1="spring is a time for flowers and trees and baby bunnles<br>"
document.write(str1)
document.write("the index for the second word ‘and' is"+str1.indexOf("and",30))
documednt.write("the last index of the word ‘and' is "+str1.lastIndexOf("and"))
</script>
9.替换字符串中的文本

<script>
str1="spring is a time for flowers and trees and baby bunnles<br>"
document.write(str1)
document .write(str1.replace("and",","))
</script>
10.字符串分离

<script>
str1="spring is a time for flowers and trees and baby bunnles<br>"
document.write(str1)
str1array=str1.split(" ")
document.write(str1array[0]+"<br>")
document.write(str1array[1]+"<br>")
document.write(str1array[2]+"<br>")
document.write(str1array[3]+"<br>")
</script>
第十章 使用日期和时间

1.使用Date对象

<script>
cdate=new Date("august 2,1989 12:30:00")
document.write(cdate)
</script>
2.显示当地时间和日期

<script>
cdate=new Date()
document.write("当前时间是:"+cdate.toGMTString()+"<br>")
document.write("日期和时间是:"+cdate.toLocaleString())
</script>
3.获得时间和日期值

<script>
cdate=new Date()
document.write("显示当前的星期"+cdate.getDay()+"<br>")
document.write("显示当前的月份"+cdate.getMonth()+"<br>")
document.write("显示当前的日期"+cdate.getDay()+"<br>")
document.write("显示当前的年份"+cdate.getYear()+"<br>")
document.write("显示当前的小时"+cdate.getHours()+"<br>")
document.write("显示当前的分钟"+cdate.getMinutes()+"<br>")
document.write("显示当前的秒"+cdate.getSeconds()+"<br>")
</script>
4.设置时间和日期值

<script language=javascript>
cdate=new Date("December 25,1984")
document.write("显示日期"+cdate+"<br>")
document.write("设置月份"+cdate.setMonth(10)+"<br>")
document.write("设置日期"+cdate.setDate(23)+"<br>")
document.write("设置年份"+cdate.setYear(2000)+
[1][2][3][4][5][6][7][8]
上一篇:入门教程:Javascript学习讲解(一)
下一篇:Sql Server数据库的备份、恢复方法
最新文章 更多
推荐文章 更多
热门文章 更多
© 2005-2010 飘网中国 版权所有
站长邮箱:①LCC-749AT163.com ②FlymornATgmail.com(AT改为@)
如转载时,请注明出处;本站部分资源来自网络,如有侵权,请来信说明;飘易文章系统 HTML版.
渝ICP备05000119号