随笔分类 -  Javascript

摘要:In my last article, i use a JSON tool to parse a JSON string, but there will be a JavaScript error:<div style="display: none;" class="initParameters">{ cred: "6B30E9A9E716C370E040E00A193871B8" }... 阅读全文
posted @ 2009-06-23 13:26 三生石上(FineUI控件) 阅读(2075) 评论(0) 推荐(0) 编辑
摘要:Today, Flyer notify me that the page is loading twice, very strange.And this is my step to solve the problem.1. Open firebugand discovertwo requests of home.do page (HTTP action - GET).2. Open HTTPWat... 阅读全文
posted @ 2009-06-15 16:20 三生石上(FineUI控件) 阅读(388) 评论(0) 推荐(1) 编辑
摘要:The observer pattern (a subset of the asynchronous publish/subscribe pattern) is a software design pattern in which an object, called the subject, maintains a list of its dependents, called observers,... 阅读全文
posted @ 2009-06-10 16:36 三生石上(FineUI控件) 阅读(903) 评论(0) 推荐(0) 编辑
摘要:Fast string concatenationWe always use + to concatenate small strings into a large one, which is considered to be a good practice.But there will be a major hit on performance if you do many string con... 阅读全文
posted @ 2009-05-18 15:07 三生石上(FineUI控件) 阅读(907) 评论(0) 推荐(0) 编辑
摘要:JavaScript doesn’t have block scopeBlock doesn’t have scope in javascript, only function has scope.for(var i = 0; i < 2; i ++) { } i; // 2If you want to create scope, use anonymous fun... 阅读全文
posted @ 2009-05-15 13:25 三生石上(FineUI控件) 阅读(645) 评论(0) 推荐(0) 编辑
摘要:Is undefined a reserved wordIt seems like so, but actually it doesn’t.var undefined = 'Hello'; undefined; // 'Hello'This may surprise you, but it does work well. undefined is just a pre-defined ... 阅读全文
posted @ 2009-05-14 13:40 三生石上(FineUI控件) 阅读(761) 评论(0) 推荐(0) 编辑
摘要:Always specify the second argument - parseIntparseInt converts a string to an int number, the syntax is:parseInt(str, [radix])The second argument is optional, which specify the radix of the first argu... 阅读全文
posted @ 2009-05-13 14:41 三生石上(FineUI控件) 阅读(1101) 评论(0) 推荐(0) 编辑
摘要:Produce boolean value from other typesAll objects in JavaScript can be converted to boolean implicitly, look at these examples:0 == false; // true1 == true; // true'' == false // truenull == false // ... 阅读全文
posted @ 2009-05-12 14:30 三生石上(FineUI控件) 阅读(2272) 评论(0) 推荐(0) 编辑
摘要:I described how to use jStore as a client-side persistent storage in my last post. The jStore manage a number of different storage engines, such as gears and flash objects. But they all need additional downloads. The IE browser has provide a mechanism called userdata behavior to store max 128kb data a page, 1024kb a domain. This is a portion of DHTML that suppoted by IE5 or later. Refer to this article: userData Behavior. 阅读全文
posted @ 2009-05-11 11:35 三生石上(FineUI控件) 阅读(547) 评论(0) 推荐(0) 编辑
摘要:In my opinion, there are two big things in Javascript's world - Closure and Prototype. Question 1. What does Prototype do in JavaScript? In a single word, it's a feature that aimed at reducing code duplication. We all know in computer world there is a famous philosophy - Don't Repeat Yourself. In classic object-oriented languages such as c++/c#/java, we have inheritance to encapsulate some common methods into a super class to reduce code lines. But in JavaScript, there is no concept o 阅读全文
posted @ 2009-05-07 15:17 三生石上(FineUI控件) 阅读(508) 评论(2) 推荐(0) 编辑
摘要:AOP stands for Aspect-oriented programming. I think the main point of this technology is the ability to add code before or after a function execution. After some digging on the internet, i write my implement of AOP in JavaScript. 阅读全文
posted @ 2009-05-06 13:20 三生石上(FineUI控件) 阅读(960) 评论(1) 推荐(0) 编辑
摘要:I used to write multiline strings in JavaScript like this:var str = 'This is ' +'a very long ' +'sentence.'Sometimes, i wrote it this way:var str = ['This is ','a very long ','sentence.'].join('');Usi... 阅读全文
posted @ 2009-05-05 17:25 三生石上(FineUI控件) 阅读(323) 评论(1) 推荐(0) 编辑
摘要:They are two similar code below: 1.function User(name) {this.name = name;}User.prototype = { 'sex': 'man' };var user = new User('Zhang');alert(User.prototype['sex']); // manalert(user.constructor.pr... 阅读全文
posted @ 2009-04-30 17:19 三生石上(FineUI控件) 阅读(391) 评论(0) 推荐(0) 编辑
摘要:类 C 语言一般都用于块级作用域,但是Javascript中的 while, if-else, for, switch-case 等控制结构不具有自己的作用域, 在Javascript中只有函数(function)具有自己的作用域,请比较如下的 C# 代码和 Javascript 代码 阅读全文
posted @ 2009-02-19 11:45 三生石上(FineUI控件) 阅读(1029) 评论(0) 推荐(0) 编辑
摘要:这是一个基础性的文章,使用Javascript观察DOM中的事件冒泡机制,并介绍如何阻止默认行为和如何组织事件冒泡的方法。分别在Firefox和IE下有对应的实现。 阅读全文
posted @ 2009-02-18 14:21 三生石上(FineUI控件) 阅读(1778) 评论(0) 推荐(2) 编辑
摘要:Currying好像是函数式语言都有的一个特性,比如Perl,Python,Javascript。 那么到底什么是Currying,我是在学习Closure时无意中接触到这个定义的,觉得很是有趣。 先看看 Wiki 中的定义: Currying is the technique of transforming a function that takes multiple arguments in such a way that it can be called as a chain of functions each with a single argument. 大概的意思就是说,将拥有多个参数的函数Currying化为拥有单一参数的函数形式。 阅读全文
posted @ 2009-02-17 15:36 三生石上(FineUI控件) 阅读(3329) 评论(1) 推荐(0) 编辑
摘要:这是一个老生常谈的问题了,不过还是拿我的解决办法来晒晒太阳。 最开始我是为Table中的每一项添加属性 class="item1" 的方式实现的,仔细分析,这里面使用的 getElementsByTagName 会把页面上所有的 input 标签都找到(包括单行文本输入框,按钮,所有的单选和多选框等),然后再执行过滤,这是一种效率不高的方法。 阅读全文
posted @ 2009-02-17 12:30 三生石上(FineUI控件) 阅读(3670) 评论(2) 推荐(1) 编辑
摘要:对于单行文本框,我们可以通过设置属性maxlength来限制可输入的最多字符数, 对于多行文本框,如果想限制最多可输入字符数,必须使用Javascript脚本来达到目的。 阅读全文
posted @ 2009-02-17 10:53 三生石上(FineUI控件) 阅读(4812) 评论(3) 推荐(0) 编辑
摘要:在Javascript中声明一个字符串,我们可以方便的使用literal(字面)语法: var str1 = 'Hello Javascript!'; var str2 = "Hello World!"; 由于在Javascript中,任何事物都是对象,所以我们也可以使用new语法创建: var str3 = new String("Hello Javascript!"); var str4 = new String("Hello World!"); 阅读全文
posted @ 2009-02-16 13:32 三生石上(FineUI控件) 阅读(1480) 评论(0) 推荐(0) 编辑