当前位置: 首页 > 图文教程 > 网络编程 > Javascript > 初学JavaScript第二章

Javascript
在一个form用一个SUBMIT(或button)分别提交到两个处理表单页面的代码
用Javascript读取中文COOKIE的解决办法
功能很全的精品JS计算器
永不消失的title提示代码
一直复略了的一个问题,关于表单重复提交
初探jquery——表单应用范例
懒就要懒到底——鼠标自动点击(含时间判断)
关于表单的两点交互体验改进技巧
javascript知识点收藏
用Javascript做flash做的事..才完成的一个类.Auntion Action var 0.1
如何使页面打开时input就被选中?
点选TOP后并不是直接跳到页顶的,而是滚动上去的
js玩一玩WSH吧
【最新漏洞】IE中使用Rds.DataSpace下载并运行病毒文件
select选择事件问题
SUN的《AJAX与J2EE》全文译了
你真的了解JavaScript吗?
极酷的javascirpt,让你随意编辑任何网页
用javascript编写的第一人称射击游戏
轻轻松松学习JavaScript

Javascript 中的 初学JavaScript第二章


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-12   浏览: 194 ::
收藏到网摘: n/a

初学JavaScript时觉得应该注意的一些知识点.(从<<JavaScript高级编程>>中学到) JavaScript的对象都是实例化了的,只可以使用而不能够创建继承于这些对象的新的子类.
window对象为所有对象的Parent
window对象的主要属性有:Name,Length,Parent,Self,Top,Status,Default Status,Opener,Closed.
window对象的主要方法有:Item,alert,blur,close,confirm,open,focus,showModalDialog.
Document对象的常用属性:alinkcolor,Anchors,bgcolor,cookie,domain,embeds,
fgcolor,layers,linkcolor,location,title,url,vlinkcolor
Anchors属性的使用:
function goNextAnchor(where)
{
window.location.hash = where ;
}
<input type="button" value="下一个" onClick="goNextAnchor('sec2')"/>
数组对象的创建:
function students(name,age)
{
this.name = name ;
this.age = age ;
}
stu1 = new students("thtwin",22) ;
stu = new Array(5) ;
stu[0] = "thtwin" ;
stu[1] = "thtwinj2ee" ;
........
stu.length //数组的长度
Math对象的相关方法使用:
Math.abs(arg) ; //求用户设置数的绝对值
Math.max(arg1,arg2) ; //返回两个数中的较大值
Math.round(arg1) ; //将浮点数舍入成它最近的一个整数>0.5进一,否则丢掉小数位
Math.floor(arg1) ; //求的是小于或等于变量的值
Math.ceil(arg1) ; //大于或等于变量的值
Math.random() ; //产生一个0到1之间的随机数
JavaScript中的日期对象:
该对象没有属性,但是可以通过一些方法来设置时间.
禁止使用1970年1月1日之前的时间.
thisDay = new Date();
thisDay = new Date(month day,year hours:minutes:seconds) ;
thisDay.getYear() ;
thisDay.getMonth() ;
thisDay.getDate() ;//返回一个月份中的日期值.这个方法直接返回一个1以31之间的日期值
thisDay.getDay() ;
thisDay.getTime() ;//返回一个代表当前日期的整数值.(192687456985)
thisDay.getHours() ;
thisDay.getMinutes() ;
thisDay.getSecondes() ;
thisDay.toLocaleString() ;//返回该时间的字符串值
With语句的使用
With(Object)
{
statements ;
}
说明:在存取对象属性和方法时不用重复指定参考对象.在With语句块中,凡是JavaScript
不识别的属性和方法都和该语句块指定的对象有关.如:
当使用与Document对象有关的write()或者writeln()方法时,往往用如下形式:
document.writeln("Hell!") ;
如果需要显示大量数据时,就会多次使用同样的document.writeln() ;语句,这时就可以
像下面的程序那样,把所有的以Document对象为参考的对象的语句放到With语句块中,从而
达到减少语句量的目的.下面是一个With语句使用的例子:
<script language="javascript">
<!--
With(document)
{
write("thtwin") ;
write("thtwinj2ee") ;
wirte("test") ;
}
//-->
</script>