// if localStorage is present, use that if (('localStorage' in window) && window.localStorage !== null) { // easy object property API localStorage.wishlist = '["Unicorn","Narwhal","Deathbear"]'; } else { // without sessionStorage we'll have to use a far-future cookie // with document.cookie's awkward API :( var date = new Date(); date.setTime(date.getTime()+(365*24*60*60*1000)); var expires = date.toGMTString(); var cookiestr = 'wishlist=["Unicorn","Narwhal","Deathbear"];'+ ' expires='+expires+'; path=/'; document.cookie = cookiestr; }
p.box { left: 40px; -webkit-transition: all 0.3s ease-out; -moz-transition: all 0.3s ease-out; -o-transition: all 0.3s ease-out; transition: all 0.3s ease-out; } p.box.totheleft { left: 0px; } p.box.totheright { left: 80px; }
// Give me a new array of all values multiplied by 10. [5, 6, 7, 8, 900].map(function(value) { return value * 10; }); // [50, 60, 70, 80, 9000] // Create links to specs and drop them into #links. ['html5', 'css3', 'webgl'].forEach(function(value) { var linksList = document.querySelector('#links'); var newLink = value.link('http://google.com/search?btnI=1&q=' + value + ' spec'); linksList.innerHTML += newLink; }); // Return a new array of all mathematical constants under 2. [3.14, 2.718, 1.618].filter(function(number) { return number < 2; }); // [1.618] // You can also use these extras on other collections like nodeLists. [].forEach.call(document.querySelectorAll('section[data-bucket]'), function(elem, i) { localStorage['bucket' + i] = elem.getAttribute('data-bucket'); });
.hwaccel { -webkit-transform: translateZ(0); }
以上がHTML5 で Web サイトのフロントエンドのパフォーマンスを向上させる方法に関するサンプル コード分析の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。