相关标签

跨浏览器的本地存储(二):DOM:Storage

DOM Storage,是基于 Web Applications 1.0 specification 中介绍的 Structured client-side storage。相比 Cookies 来说,DOM Stroage 空间更大、更安全、更易于使用的。目前它只在基于Moziila的浏览器中可以使用,从 Firefox2 开始。
一、DOM:Storage: sessionStorage
浏览器支持:Firefox 2.0+
基本语法:

// 设置 key 值
sessionStorage.key = value;
// 获取 key 值
value = sessionStorage.key;

备注:

作为每个 window 对象的属性存在的全局对象,即:可以通过 sessionStorage 或者 window.sessionStorage 来访问它们。
sessionStorage 含有一个在页面会话有效期内(只要页面没有关闭,一个页面会话就始终保持着,且当页面被重新载入或恢复时“复活”,而打开一个新的标签页或新窗口都会初始化新的会话)可用的存储区域。
sessionStorage 持有那些应该保存的临时数据,... 3 条评论 »

通过 Dom 方法提高 innerHTML 性能

function replaceHtml(el, html) {
var oldEl = typeof el === “string” ? document.getElementById(el) : el;
/*@cc_on // 原始的 innerHTML 在 IE 中的性能好一点
oldEl.innerHTML = html;
return oldEl;
@*/
var [...]

... 5 条评论 »