代码改变世界

用 PHP 读取和编写 XML DOM

2012-09-22 02:02 by youxin, 312 阅读, 0 推荐, 收藏,
摘要:使用 DOM 库读取 XML读取格式良好的 XML 文件最容易的方式是使用编译成某些 PHP 安装的文档对象模型 (DOM)库。DOM 库把整个 XML 文档读入内存,并用节点树表示它,如图 1 所示。<books> <book> <author>Jack Herrington</author> <title>PHP Hacks</title> <publisher>O'Reilly</publisher> </book> <book> <author>J 阅读全文

javascript 函数的 bind() 方法

2012-09-21 22:05 by youxin, 618 阅读, 0 推荐, 收藏,
摘要:For a given function, creates a bound function that has the same body as the original function. Thethisobject of the bound function is associated with the specified object, and has the specified initial parameters.function.bind(thisArg[,arg1[,arg2[,argN]]])传入的第一个参数被赋值给thisthisArg :The value to be pa 阅读全文

setInterval/setTimeout 中this无效

2012-09-21 21:48 by youxin, 1076 阅读, 0 推荐, 收藏,
摘要:The execution context,thisThe button below should change it’s value to ‘OK’, but it doesn’t work. Why?The reason iswrongthis.Functions executed bysetInterval/setTimeouthavethis=window, orthis=undefinedin ES5 strict mode. 也就是说this指向了window。The reference is usually passed through closure. The followin 阅读全文

clientWidth offsetWidth innerWidth 区别(窗口尺寸 汇总)

2012-09-21 21:33 by youxin, 7818 阅读, 3 推荐, 收藏,
摘要:scrollWidth是对象的实际内容的宽,不包边线宽度,会随对象中内容的多少改变(内容多了可能会改变对象的实际宽度)。clientWidth是对象可见的宽度,不包滚动条等边线,会随窗口的显示大小改变。offsetWidth是对象的可见宽度,包滚动条等边线,会随窗口的显示大小改变。一个scrollWidth和clientWidth的例子:77.htm文件在文本框内输入内容,当横向滚动条没出来前scrollWidth和clientWidth的值是一样的。当一行内容超出文本框的宽度,就有横向滚动条出来了,scrollWidth的值就变了。scrollWidth是对象实际内容的宽度。clientWi 阅读全文

javascript for循环中的闭包

2012-09-21 19:54 by youxin, 222 阅读, 0 推荐, 收藏,
摘要:注意我们的links.length为3;0 1 2 可是实际运行时点击任何一个链接都是 4. 为什么? 因为当闭包函数被调用时,他引用的是最后一次的赋值。 解决办法: 用一个匿名函数来激发作用域: 还有很多的解决办法: http://www.cnblogs.com/snandy/archive/20 阅读全文

精通javascript:元素的可见性

2012-09-20 18:07 by youxin, 1685 阅读, 0 推荐, 收藏,
摘要:元素的可见性 css有2种不同样式可以有效地隐藏元素,他们均有自己的优缺点。但会导致不同的结果。1.visibility属性在切换元素可见性的同时会保持元素普通流的属性的相关影响。他们2个值;visible 和hidden,假设一小段文本包含在b标签内,同时b的visibility设置为hidden,那么结果就是文本内有一小块空白,它的尺寸刚好等于被包裹文本的原有尺寸。比较以下2行文本普通问题// Normal text:Hello John, how are you today?// 'John' has visibility: hidden applied to itHel 阅读全文

精通javascript:元素的尺寸

2012-09-20 18:05 by youxin, 242 阅读, 0 推荐, 收藏,
摘要:找出元素的高度和宽度可以很容易,也可以很困难,取决于他所处的不同场合。在大多数情况下,仅仅需要使用getStyle函数的修改版本就可以得到当前元素的高度和宽度。// Get the actual height (using the computed CSS) of an elementfunction getHeight( elem ) { // Gets the computed CSS value and parses out a usable number return parseInt( getStyle( elem, ‘height’ ) );}// Get the ac... 阅读全文

精通javascript:获取位置

2012-09-20 17:27 by youxin, 325 阅读, 0 推荐, 收藏,
摘要:To start with, let’s look at finding an element’s position within a page. You have a coupleelement properties at your disposal 在你支配下 that you can use to find this information. All modernbrowsers support the following three properties; how they handle them, however, is anothermatter:offsetParent: The 阅读全文

javascript 获取元素的真实,最终的css样式

2012-09-20 16:46 by youxin, 893 阅读, 0 推荐, 收藏,
摘要:elem.style.xxx 只能获取内联的css属性,对<head>内的或link 外部样式的无能为力。<style>h1{font-size:1.6em;color:red;}</style></head><body><h1 id="title">hello world</h1><p>this is a test txt</p><script>var x=document.getElementById("title");docume 阅读全文

javascript对象小问题

2012-09-20 15:42 by youxin, 275 阅读, 0 推荐, 收藏,
摘要:看下面的代码:定义了一个对象直接量:var person={ name:"jack", setName:function(name){ this.name=name; }, getName:function(){ return name; ... 阅读全文
上一页 1 ··· 207 208 209 210 211 212 213 214 215 ··· 269 下一页