Cookie

  1. 网页上所有元素都有一个style对象,借此可以获得网页上任何事物的高度和宽度。document.getElementById("rockImg").style.height
  2. 浏览器大小改变触发onresize事件。
  3.   alert(typeof document.cookie);  //string
  //写Cookie
        function writeCookie(name, value, days) {
            var expires = "";
            if (days) {
                var date = new Date();
                date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
                expires = ";expires=" + date.toGMTString();
            }
            document.cookie = name + "=" + value + expires + ";path=/";
        }
        //读取Cookie
        function readCookie(name) {
            var searchName = name + "=";
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var c = cookies[i];
                while (c.charAt(0) == ' ') {
                    c = c.substring(1, c.length);
                }
                if (c.indexOf(searchName) == 0) {
                    return c.substring(searchName.length, c.length);
                }
            }
            return null;
        }
        //清除Cookie
        function eraseCookie(name) {
            writeCookie(name, "", -1);
        }
原文地址:https://www.cnblogs.com/hometown/p/3236008.html