大佬教程收集整理的这篇文章主要介绍了HTML5触摸界面设计与开发 读书笔记,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
//内存层 var memoryCache={}; var CACHE_TTL=864000000; var CACHE_PREFIX="ti"; function setCache(mykey,data){ var stamp,obj; stamp=Date.Now(); obj={ date:stamp,data:data }; //localstorage层 localStorage.setItem(CACHE_PREFIX+mykey,JSON.Stringify(obj)); memoryCache[CACHE_PREFIX+mykey]=obj; } console.log(window); function getCached(mykey){ var key,obj; key=CACHE_PREFIX+mykey; if(memoryCache[key]){ if(memoryCache[key].date-Date.Now()>CACHE_TTL){ return false; } return memoryCache[key].data; } obj=localStorage.getItem(key); if(obj){ obj=JSON.parse(obj); if(Date.Now()-obj.date>CACHE_TTL){ localStorage.removeItem(key); delete(memoryCache[key]); return false; } memoryCache[key]=obj; return obj.data; } } setCache('lilu',39); getCached('lilu'); console.log(memoryCache['tililu']); console.log(localStoragE);
localStorage可以存放5MB的内容
以下公式可以计算localStorage的空间是否已经满了
1024*1024*5-unescape(encodeURIComponent(JSON.Stringify(localStoragE))).length
<html manifest="birds.appcache">
CACHE MANIFEST # The date below is a simple # way to make sure I change this #file # 2013-03-15r4 jquery-1.8.0.min.js gull-360x112.jpg gull-640x360.jpg gull-720x225.jpg falLBACK: NETWORK: *
使用自定义事件
function togglePicture(){ var h=document.querySELEctor('.picture'); if(h.style.display=="none"){ h.style.display="block"; }else{ h.style.display="none"; } } window.addEventListener('tap',function(E){ togglePicture(); }) window.addEventListener('touchstart',function(E){ var tap=document.createEvent('CustomEvent'); tap.initCustomEvent('tap',true,null); window.dispatchEvent(tap); });
以上是大佬教程为你收集整理的HTML5触摸界面设计与开发 读书笔记全部内容,希望文章能够帮你解决HTML5触摸界面设计与开发 读书笔记所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。