title: Getting the following code to work in both Chrome and Safari
body: <p>Can't seem to figure out why this works in Safari but not in chrome. Any help would be much appreciated.</p>
  
  <pre><code>//Create or use existing DB
  var db = openDatabase('myTest', '1.0', 'mySpecialDatabase', 200000);
  
  if (db) {
    //New Transaction
    db.transaction(function (tx) {
    tx.executeSql('DROP TABLE IF EXISTS foo');    
    tx.executeSql('CREATE TABLE IF NOT EXISTS foo (id unique, text)');
    //Insert test data
    tx.executeSql('INSERT INTO foo (id, text) VALUES (1, "myTest")');
    tx.executeSql('INSERT INTO foo (id, text) VALUES (2, "another")');
    tx.executeSql('INSERT INTO foo (id, text) VALUES (3, "andYetAnother")');
    tx.executeSql('INSERT INTO foo (id, text) VALUES (4, "ohAndAgain")');
      });
      alert("DB success");     
   }
  else {
      alert("Oooops");
  }
  
  db.transaction(function (tx) {
      // Loop rows of DB, print values
      tx.executeSql('SELECT * FROM foo',[], function (tx, results) {
          var rows = results.rows;
          alert(rows.length);
          for (var index = 0; index &lt; rows.length; index++) {
              var x = rows.item(index);
              alert(x.text);
          }
      });
  });
  </code></pre>
  
  <p>Throw it in JSFiddle in either browser, works as intended in latest release of Safari but no such luck in chrome.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I managed to get it working in the end - code can be seen below.</p>
  
  <pre><code>var db = openDatabase('CBDB', '1.0', 'mySpecialDatabaseThatWontWork',10*1024*1024);
  
  db.transaction(function (tx){
   tx.executeSql('DROP TABLE IF EXISTS cb');
   alert("dropped table");
   createDB();
   queryDB();
  },
  function (tx, error) {
      // error
      alert('0.Something went wrong: '+ error.message);
  });
  
  function createDB(){
      db.transaction(function (tx) {       
          tx.executeSql('CREATE TABLE IF NOT EXISTS cb (id unique, text)');
          tx.executeSql('INSERT INTO cb (id, text) VALUES (1, "myTest")');
          tx.executeSql('INSERT INTO cb (id, text) VALUES (2, "another")');
          tx.executeSql('INSERT INTO cb (id, text) VALUES (3, "andYetAnother")');
          tx.executeSql('INSERT INTO cb (id, text) VALUES (4, "ohAndAgain")');
          alert("DB success");  
          },
          function (tx, error) {
              // error
              alert('1.Something went wrong: '+ error.message);
          });
  }
  
  function queryDB(){
      db.transaction(function (tx) {
          tx.executeSql('SELECT * FROM cb',[], function (tx, results) {
              var rows = results.rows;
              alert(rows.length);
              for (var index = 0; index &lt; rows.length; index++) {
                  var x = rows.item(index);
                  alert(x.text);
              } 
          },
          function (tx, error) {
          // error
          alert('2.Something went wrong: '+ error.message);
          });
      });
  }
  </code></pre>