随笔分类 -  JavaScript

摘要:windowinnerHeightSets or returns the inner height of a window's content areainnerWidthSets or returns the inner width of a window's content areaouterHeightSets or returns the outer height of a window, including toolbars/scrollbarsouterWidthSets or returns the outer width of a window, includi 阅读全文
posted @ 2013-09-25 11:52 Acacia Sun 阅读(585) 评论(0) 推荐(0)
摘要:offsetLeft/offsetTop当前元素距浏览器边界的偏移量,从border边缘算起。clientTop/clientLeft这个属性测试下来的结果是=border。scrollLeft/scrollTop(IE6计算方式不同)设置或返回已经滚动到元素的左边界或上边界的像素数。 阅读全文
posted @ 2013-09-24 23:15 Acacia Sun 阅读(207) 评论(0) 推荐(0)
摘要:scrollWidth/scrollHeight:可滚动部分的尺寸offsetWidth/offsetHeight:width/height+padding+border,不包含marginclientWidth/clientHeight:如果当前元素是根元素(document.documentElement),这两个属性将返回window的尺寸,它们是除去滚动条及其他浏览器“包装”(Chrome)之外内部或视口的尺寸。在其他情况下,这两个属性返回元素的内容加上内边距的尺寸width+padding,不包含scrollbar 阅读全文
posted @ 2013-09-24 21:04 Acacia Sun 阅读(525) 评论(0) 推荐(0)
摘要:每个类都有一个prototype属性,这是一个静态属性,该属性值包含了标识该类的一个对象,这个对象称为原型对象。在原型对象上定义了一些内部属性用于描述该类,其中就包含了该类的基类信息。通过该信息,JavaScript解释引擎就可以知道该类的基类。同时基类也有相同的构成,因此JavaScript解释引擎就可以知道基类的基类,这就建立起了一个链条,因为描述基类信息的内部属性称为[Prototype],所以,该链条也被称为原型链(prototype chain)。原型链条的尽头是Object的原型对象,该对象的内部属性[Prototype]的值是null。参考:张亚飞,《JavaScript权威指南 阅读全文
posted @ 2013-08-26 22:06 Acacia Sun 阅读(191) 评论(0) 推荐(0)
摘要:1、typeof 2、void void 运算符是避免表达式返回值。 使用方法:void expression 其中expression 参数是任意有效的 JScript 表达式。 void运算符说明 void 运算符对表达式求值,并返回 undefined。在希望求表达式的值,但又不希望脚本的剩余部分看见这个结果时,该运算符最有用。3、instancof4、in 阅读全文
posted @ 2013-08-17 11:37 Acacia Sun 阅读(206) 评论(0) 推荐(0)
摘要:下面列出的是三种常用的方式1、在元素标签中给事件属性赋值(所有浏览器都支持)测试1:html代码:testjs代码:function test(){for(var i=0;i');}}结果:1[object MouseEvent]2测试2:html代码:testjs代码:function test(arg1,arg2,…,argN){for(var i=0;i');}}结果:什么也不输出结论:testhere处有几个参数,就传进几个参数,不受test函数的形参个数影响event参数用“event”关键字传递如果什么参数也不传,IE浏览器可以通过window.event获得事件对 阅读全文
posted @ 2013-06-02 15:28 Acacia Sun 阅读(460) 评论(0) 推荐(0)
摘要:1.用document.styleSheets获得通过style标签和link标签加入的样式返回类型var styleSheetList=document.styleSheets;//object StyleSheetListvar styleSheet=document.styleSheets[i];//object CSSStyleSheetvar cssRuleList=document.styleSheets[i].cssRules;//object CSSRuleListvar cssRule=document.styleSheets[i].cssRules[j];//object 阅读全文
posted @ 2013-06-01 18:25 Acacia Sun 阅读(352) 评论(0) 推荐(0)