javascript userdata操作

要注意此方法只能对同一目录有效
var Session = {
    isinit: false,
    init: function() {
        SessionObj = document.createElement('input');
        SessionObj.type = "hidden";
        SessionObj.id = "Sessionid";
        SessionObj.style.behavior = "url('#default#userData')"
        document.body.appendChild(SessionObj);
        this.isinit = true;
    },
    save: function(sessionName, value) {
        this.isinit ? '' : this.init();
        if (sessionName != null && sessionName != "") {
            SessionObj.setAttribute(sessionName, value)
            SessionObj.save("s")
        }
    },
    load: function(sessionName) {
        this.isinit ? '' : this.init();
        if (sessionName != null && sessionName != "") {
            SessionObj.load("s");
            return SessionObj.getAttribute(sessionName);
        }
    }
}

posted on 2010-08-07 12:06  SkyZhang  阅读(234)  评论(0)    收藏  举报

导航