ITeye博客

js & css

共 6 篇文章

用JavaScript实现截取指定长度的HTML字符串

/* * 调整截取的字符串的位置。因为在截取一个字符串后可能存在两种情况: * (1)字符串末位正好处于一个标签的属性之中的某个位置。如:<a id="xxx" href="xxx" ></a>中红色标注的位置。 * (2)字符串末位处于一个标签内容之中的某个位置。如:<a >here </a> 中红色标注的位置。 * 对于这两种情况,第二种情况可以无需特殊处理,但是第一种情况的话得将整个标签删除或者将其属性补全。删除的话 * 将字符串的末尾位置前移至标签开始之前;而补全则是将末尾位置后移至次标签的'>'处。这里采用的是删除的方法。 */ function adjustByTagPostio…

2008-09-23 13:25 · js & css · HTML · JavaScript

javascript中==和===操作符的比较

摘引至" JavaScript: The Definitive Guide, 5th Edition " chapter 5 section 4 In JavaScript, numbers, strings, and boolean values are compared by value . In this case, two separate values are involved, and the == and === operators check that these two values are identical. On the other hand, objects, ar…

2008-08-26 15:30 · js & css · JavaScript

mootools Class 继承机制

var Class=function(B) { var A=function() { // 存在initialize函数的话就执行此函数,否则直接返回 // arguments[0] 在什么情况下会 === null ? return(arguments[0]!==null&&this.initialize&&$type(this.initialize)=="function")?this.initialize.apply(this,arguments):this; }; $extend(A,this); A.prototype=B; A.constructor=Class; return …

2008-08-26 14:59 · js & css · C · Mootools · C++ · C# · prototype

javascript prototype 继承

js中基于prototype实现继承的基本代码如下所示: function(SubClass, SuperClass){ function F(){} // F.prototype = SuperClass.prototype; // 实现继承的关键,构造 prototype chain SubClass.prototype = new F(); // 1 // 重置子类prototype对象的constructor属性为子类本身。 SubClass.prototype.constructor = SubClass; // 设置子类的superclass属性值为父类的prototype。 S…

2008-08-26 12:34 · js & css · PHP · EXT · F# · prototype · JavaScript

javascript 执行模型的一些测试

一 js的扫描过程 js在执行代码之前,会有一个扫描(相当于预编译)的过程,这一过程用于获取定义的变量名和函数对象。主要包括如下几个处理步骤: 碰到了“var instance=xxx;” 这样的语句时,则在当前variable object上添加此属性,赋初值为undefined 碰到了函数的定义"function func(){}"时,则使用此函数定义创建相应的函数对象,然后在varable object对象上添加此属性func,其值为返回的函数对象。 下面来举例分析这一过程。 // a var local_v = "local v"; global_v = "global v"; al…

2008-08-21 17:15 · js & css · 浏览器 · JavaScript

javascript object model

the difference between prototype property and [[prototype]] which constructs the chain of prorotype each object has a inner property called '[[prototype]] ', whose value is null or point to some object. This property is visible only for JS engine.(in firefox, this property can visited by name '__pr…

2008-05-26 17:39 · js & css · F# · prototype · Firefox · JavaScript