如何咨询TChromium上的LocalStorage数据库?

时间:2017-05-12 17:58:41

标签: javascript delphi tchromium

如何基于Delphi应用程序中的TChromim组件从浏览器操作LocalStorage?但是,要使用Javascript创建它,我需要咨询Delphi。以下是我如何创建LocalStorage并使用javascript进行处理的示例:

chromium.Browser.MainFrame.ExecuteJavaScript("
var db = openDatabase('myDB', '1.0', 'Test DB', 2 * 1024 * 1024);
var msg,sql;
var maior, i;


db.transaction(function (qry) {
   qry.executeSql('CREATE TABLE IF NOT EXISTS  myTable   (
                  id_link INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
                  link TEXT NOT NULL 
            );', [], null, null);     
});

db.transaction(function (qry) {
   sql = 'INSERT INTO myTable ( link) VALUES (".com.br")';
   console.log(sql);
   qry.executeSql(sql, [], null, null);  

});

db.transaction(function (qry) {
   qry.executeSql('SELECT * FROM myTable', [], function (qry, results) {
      var len = results.rows.length;
      msg = "Total Registros da busca: " + len ;
      console.log(msg);

      for (i = 0; i < len; i++){
          msg =  results.rows.item(i).id_link + " - " +results.rows.item(i).link;
         console.log(msg);
      }
   }, null);
}); ", '', 0);

谢谢。

0 个答案:

没有答案