代码改变世界

javascript Event对象详解

2012-08-28 13:08 by youxin, 364 阅读, 0 推荐, 收藏,
摘要:Represents the state of an event, such as the element in which the event occurred, the state of the keyboard keys, the location of the mouse, and the state of the mouse buttons.Event代表事件状态,如事件发生的元素,键盘状态,鼠标位置和鼠标按钮状态。一旦事件发生,便会生成Event对象,如单击一个按钮,浏览器的内存中就产生相应的 event对象。event对象只在事件发生的过程中才有效。event的某些属性只对特定的 阅读全文

转:JavaScript中绑定事件监听函数的通用方法

2012-08-28 01:05 by youxin, 345 阅读, 0 推荐, 收藏,
摘要:事件绑定的3中常用方法:传统绑定、W3C绑定方法、IE绑定方法。但是,在实际开发中对于我们来讲重要的是需要一个通用的、跨浏览器的绑定方法。如果我们在互联网上搜索一下会发现许多方法,一下是比较知名的几种方法:在开始学期下面几种方法之前,应当讨论一下,一个好的addEvent()方法应当达到哪些要求: a、支持同一元素的同一事件句柄可以绑定多个监听函数; b、如果在同一元素的同一事件句柄上多次注册同一函数,那么第一次注册后的所有注册都被忽略; c、函数体内的this指向的应当是正在处理事件的节点(如当前正在运行事件句柄的节点); d、监听函数的执行顺序应当是按照绑定的顺序执行; e、在函... 阅读全文

javascript闭包

2012-08-28 00:45 by youxin, 196 阅读, 0 推荐, 收藏,
摘要:ecmascript最让人误解的一点是他支持闭包。所谓闭包,是指词法表示包括不必计算的变量的函数。也就是说,该函数能使用函数外定义的变量。在ecmascript中使用全局变量时一个简单的闭包实例:var sMessage="hello world";function sayHelloWorld(){ alert(sMessage);}sayhelloworld();会输出helloworld。在一个函数中定义另外一个函数会使闭包更复杂。var iBaseNum=10;function addNumbers(iNum1,iNum2){ function doAddition( 阅读全文

javascript 事件处理

2012-08-27 23:59 by youxin, 461 阅读, 0 推荐, 收藏,
摘要:W3C calls the target of the event target, while Microsoft calls it srcElement。w3c把时间的目标对象称为target,而微软称之为srcElement。事件分为3类。Mouse events, caused by a certain mouse action.Keyboard events, caused by a certain key action.Interface events, 接口事件which fire when something happens to the page, for instance, 阅读全文

Javascript DOM 编程艺术:ENHANCING CONTENT

2012-08-27 02:41 by youxin, 791 阅读, 0 推荐, 收藏,
摘要:作者首先提出问题:对于标签(markup)中的属性(attribute)来说,不同浏览器往往有不同的处理方法。比如 <img alt="..." title="..."/>,有些浏览器把 alt 属性当做 tooltip,但有些则把 titile 当做 tooltip。总的来说就是,当一个标签中有 attr 时,你就得听不同浏览器的摆布,它说怎么干就怎么干。为了从它手中夺回这个权利,我们可以使用一些 JS 代码来进行处理。 作者举出了第一个实例,为一篇 web 页面动态创建缩略语(abbreviation)的列表。大家知道,我们可以使用 &l 阅读全文

js prototype

2012-08-25 16:34 by youxin, 755 阅读, 1 推荐, 收藏,
摘要:(个人注:这篇转载的文章有许多错误,其中最重要的一条就是认为prototype构成了原型链,这是错误的。原型链与prototype没有任何关系。prototype仅仅是提供了对象的共享机制。真正与原型链有关的是__Proto__属性。)ECMAScript可以识别两种类型的对象,一种叫做Native Object属于语言范畴;一种叫做Host Object,由运行环境提供例如document对象,Dom Node等Native objects是一种松散的结构并且可以动态的增加属性(property),所有的属性都有一个名字和一个值,这个值可以是另一个对象的引用或者是内建的数据类型(String 阅读全文

javascript语言精粹:函数

2012-08-25 16:23 by youxin, 304 阅读, 1 推荐, 收藏,
摘要:Functions in JavaScript are objects. Objects are collections of name/value pairs havinga hidden link to a prototype object. Objects produced from object literals arelinked to Object.prototype. Function objects are linked to Function.prototype(which is itself linked to Object.prototype). Every functi 阅读全文

Javascript DOM 编程艺术:Creating Markup on the Fly

2012-08-25 00:57 by youxin, 424 阅读, 0 推荐, 收藏,
摘要:考虑下面的代码:<div id="testdiv"> 空白也是节点<p>This is <em>my</em> content.</p></div>This is how the Document Object Model sees the markup inside “testdiv”, as shown inFigure 7-1:Dom是这么看的:笔记:其实这幅图有错误,一个元素的属性节点不是此元素的子节点。 看下面的代码:var test=document.getElementById(" 阅读全文

php solutions:创建画廊

2012-08-24 23:32 by youxin, 405 阅读, 0 推荐, 收藏,
摘要:画廊原型如下:我们想要定义画廊的缩略图为两列。This is how it works. Let’s say you want two cells in each row. When the first cell is inserted,the counter is set to 1. If you divide 1 by 2 with the modulo operator (1%2), the result is 1.When the next cell is inserted, the counter is increased to 2. The result of 2%2 is 0. 阅读全文

转:Node和Element的区别

2012-08-24 00:46 by youxin, 1524 阅读, 0 推荐, 收藏,
摘要:XmlElement is a subclass of XmlNode (and so is XmlAttribute, XmlText, XmlDocument, etc.). There is no performance implication of using one over the other at all, since XmlNode is simply the base class for all types of nodes in a DOM Xml document instance. It just so happens, that many of the APIs i. 阅读全文
上一页 1 ··· 213 214 215 216 217 218 219 220 221 ··· 269 下一页