一些经验总结

1. opera:往cookie写json形式的字符串时,一定要用encodeURIComponent进行编码。否则,不能写成功。

2. ie中JS不能通过取下标[]的方式,存取字符串的单个字符,应该用charAt。

3. 可以用setTimeout做一些例行的事情。

4. 逻辑中可以建立id与节点的映射,便捷操作。

5. 较深地JS模板引擎。

6. delete可以删除对象属性,数组元素,包括window里的变量,但不能删除函数中申明变量。

7. 可以使用String(),Boolean()等,将对象类型转换成原始类型,不明白为什么typeof(Date())==string,而不是number。Object将原始类型转换为对象类型,不管有无new,

 若参数为对象类型,则直接返回。

8.IE6早期版本,不支持gzip压缩,所以,响应压缩后的数据是无法解析的。

9. void 表达式;计算表达式结果,将结果转换为空。

11.<a>的href和onclick皆具备时,先执行onclick再执行,再做跳转。

12.browser->server

form的属性encType,target(可做无刷新上传文件),method:get/post encType=application/x-www-form-urlencoded|multipart/form-data

  传送文件encType=“multipart/form-data

  Content-Type: multipart/form-data; boundary=AaB03x  
      
     --AaB03x  
     Content-Disposition: form-data; name="submit-name"  
      
     Larry  
     --AaB03x  
     Content-Disposition: form-data; name="file"; filename="file1.dat"  
     Content-Type: application/octet-stream  
      
     ... contents of file1.dat ...  
     --AaB03x-- 

 

13.server-browser:  Transfer-Encoding: chunked

HTTP/1.1 200 OK
Server: Tengine
Date: Mon, 05 Sep 2011 14:30:44 GMT
Content-Type: application/x-javascript
Last-Modified: Thu, 27 May 2010 07:19:58 GMT
Transfer-Encoding: chunked
Connection: close
Vary: Accept-Encoding
Expires: Thu, 02 Sep 2021 14:30:44 GMT
Cache-Control: max-age=315360000
Content-Encoding: gzip

\r\n

<chunk-size> \r\n   (其中,chunk-size = chunk-data.getBytes().length,不包含\r\n)

<chunk-data> \r\n

<chunk-size> \r\n 

<chunk-data> \r\n

<0> \r\n\r\n  (chunk 结束)

posted @ 2012-03-07 23:42  wuhao12  阅读(176)  评论(0编辑  收藏  举报