classList:现在element加入了classList属性,用于访问其class列表,比如想要切换一个目标的css big类,则调用target.classList.toggle("big")即可
addEvent(window, 'storage', function (event) { if (event.key == 'storage-event-test') { output.innerHTML = event.newValue; } });
if (navigator.geolocation){ navigator.geolocation.getCurrentPosition(function(position){ alert("latitude:" + position.coords.latitude + "longitude:" + position.coords.longitude); }, function(msg){ }); }
postMessage:两个iframe间使用postMessage来通讯,可以同域甚至跨域
var db = openDatabase('foo', '1.0', 'foo', 2 * 1024); db.transaction(function (tx) { tx.executeSql('CREATE TABLE IF NOT EXISTS foo (id unique, text)'); tx.executeSql('INSERT INTO foo (id, text) VALUES (1, "foobar")'); document.querySelector('#status').innerHTML = '<p>foo created and row inserted.</p>'; }); db.transaction(function (tx) { tx.executeSql('DROP TABLE foo'); // known to fail - so should rollback the DROP statement tx.executeSql('INSERT INTO foo (id, text) VALUES (1, "foobar")'); }, function (err) { document.querySelector('#status').innerHTML += '<p>should be rolling back caused by: <code>' + err.message + '</code></p>'; }); db.transaction(function (tx) { tx.executeSql('SELECT * FROM foo', [], function (tx, results) { document.querySelector('#status').innerHTML += '<p>found rows (should be 1): ' + results.rows.length + '</p>'; }, function (tx, err) { document.querySelector('#status').innerHTML += '<p>failed (rollback failed): <em>' + err.message + '</em></p>'; document.querySelector('#status').className = 'error'; }); });