一.今日所学内容 1.history window.history.length:历史列表长度 history.back(); 返回上一页 history.go(n); 0--刷新 正数前进 负数后退 history.forward(); 前往下一页 PS:都是通过缓存来访问,不是要求服务器发送新的网页,所以不影响length长度 2.offset e.clientX/Y---依据整个页面的坐标 e.offsetX/Y---依据自己内部的坐标 box.clientLeft/Top---依据盒子相对浏览器的距离左和上 box.offsetWidth/Height---box自己的宽和高 3.web存储 localStorage:本地存储(永久存储机制,只能手动删除) localStorage.setItem('属性',值);---添加修改 localStorage.getItem('属性');---查看 localStorage.removeItem('属性');---删除单个 localStorage.clear();---清空数据 sessionStorage:会话存储(浏览器打开到关闭,临时存储,自动删除) 4.获取对象或者数组 用JSON方法转为字符串---JSON.stringify(对象名); 然后用---JSON.parse();-----把字符串转为对象 5.JSON的两个方法 JSON.stringify();----把对象转为字符串 JSON.parse();-----把字符串转为对象
|