在最近几天我试图用Javascript,HTML和CSS实现Phonegap的应用程序,但是我有一个问题......当我从谷歌Chrome运行它时,应用程序启动,但通过另一个浏览器或android它没有。我试图解决它,但对我来说一切都很好。你能帮帮我吗?
第一页
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="msapplication-tap-highlight" content="no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width" />
<!-- This is a wide open CSP declaration. To lock this down for production, see below. -->
<meta http-equiv="Content-Security-Policy" content="default-src * 'unsafe-inline'; style-src 'self' 'unsafe-inline'; media-src *" />
<!-- Good default declaration:
* gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
* https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
* Disables use of eval() and inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
* Enable inline JS: add 'unsafe-inline' to default-src
* Enable eval(): add 'unsafe-eval' to default-src
* Create your own at http://cspisawesome.com
-->
<!-- <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: 'unsafe-inline' https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *" /> -->
<link rel="stylesheet" type="text/css" href="css/base.css" />
<title>Viaggio Ideale</title>
<script type="text/javascript" charset="utf-8" src="js/SQLitePlugin.js"></script>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady(){
var db = window.openDatabase("ViaggioIdeale_DB", "1.0", "ViaggioIdeale", 200000);
db.transaction(populateDB, errorCB);
}
function populateDB(tx) {
tx.executeSql('DROP TABLE IF EXISTS USA');
tx.executeSql('CREATE TABLE IF NOT EXISTS USA (id INTEGER PRIMARY KEY AUTOINCREMENT, Nome TEXT NOT NULL, Clima TEXT NOT NULL, Interesse TEXT NOT NULL, Tipologia TEXT NOT NULL)');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Alabama", "Mite", "Sport", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Alabama", "Mite", "Musica", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Alabama", "Mite", "Carnevale", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Alabama", "Mite", "Musei", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Alaska", "Rigido", "Ghiacciai", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Alaska", "Rigido", "Natura Estrema", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Arizona", "Arido", "Deserti", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Arizona", "Arido", "Canyon", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Arizona", "Arido", "Natura Estrema", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Arkansas", "Mite", "Musei", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Arkansas", "Mite", "Natura", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Arkansas", "Mite", "Fiumi", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("California", "Vario", "Natura Estrema", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("California", "Vario", "Grattacieli", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("California", "Vario", "Spiagge", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("California", "Vario", "Parchi Divertimento", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("California", "Vario", "Cucina", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("California", "Vario", "Deserti", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("California", "Vario", "Casinò", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("California", "Vario", "Cinema", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("California", "Vario", "Night Life", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Colorado", "Arido", "Natura Estrema", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Colorado", "Arido", "Canyon", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Colorado", "Arido", "Cucina", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Colorado", "Arido", "Deserti", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Connecticut", "Vario", "Musei", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Delaware", "Mite", "Musei", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Delaware", "Mite", "Natura", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Delaware", "Mite", "Estate", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Delaware", "Mite", "Festival", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Florida", "Vario", "Spiagge", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Florida", "Vario", "Grattacieli", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Florida", "Vario", "Parchi Divertimento", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Florida", "Vario", "Natura Estrema", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Florida", "Vario", "Night Life", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Georgia", "Arido", "Natura Estrema", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Hawaii", "Tropicale", "Natura Estrema", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Hawaii", "Tropicale", "Spiagge", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Hawaii", "Tropicale", "Natura Estrema", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Hawaii", "Tropicale", "Spiagge", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Hawaii", "Tropicale", "Natura Estrema", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Hawaii", "Tropicale", "Spiagge", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Hawaii", "Tropicale", "Mare", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Idaho", "Vario", "Natura Estrema", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Idaho", "Vario", "Parchi Divertimento", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Illinois", "Continentale", "Grattacieli", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Illinois", "Continentale", "Natura", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Illinois", "Continentale", "Musei", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Illinois", "Continentale", "Cucina", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Illinois", "Continentale", "Laghi", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Illinois", "Continentale", "Fiumi", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Illinois", "Continentale", "Night Life", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Illinois", "Continentale", "Parchi Divertimento", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Indiana", "Vario", "Grattacieli", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Indiana", "Vario", "Natura", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Indiana", "Vario", "Musei", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Indiana", "Vario", "Laghi", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Iowa", "Continentale", "Cucina", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Iowa", "Continentale", "Musei", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Kansas", "Vario", "Grattacieli", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Kansas", "Vario", "Musei", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Kansas", "Vario", "Fiumi", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Kansas", "Vario", "Natura", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Kentucky", "Mite", "Cucina", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Louisiana", "Sub-Tropicale", "Cucina", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Louisiana", "Sub-Tropicale", "Carnevale", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Louisiana", "Sub-Tropicale", "Musei", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Louisiana", "Sub-Tropicale", "Night Life", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Maine", "Vario", "Natura", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Maryland", "Sub-Tropicale", "Cucina", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Maryland", "Sub-Tropicale", "Musei", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Massachusetts", "Vario", "Grattacieli", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Massachusetts", "Vario", "Musei", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Massachusetts", "Vario", "Natura", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Massachusetts", "Vario", "Night Life", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Michigan", "Continentale", "Musei", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Michigan", "Continentale", "Natura", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Michigan", "Continentale", "Grattacieli", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Michigan", "Continentale", "Laghi", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Minnesota", "Continentale", "Musei", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Minnesota", "Continentale", "Laghi", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Minnesota", "Continentale", "Natura", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Mississipi", "Sub-Tropicale", "Fiumi", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Mississipi", "Sub-Tropicale", "Natura", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Missouri", "Continentale", "Fiumi", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Missouri", "Continentale", "Natura", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Missouri", "Continentale", "Grattacieli", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Montana", "Vario", "Natura Estrema", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Nebraska", "Vario", "Natura", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Nebraska", "Vario", "Musei", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Nevada", "Arido", "Deserti", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Nevada", "Arido", "Natura Estrema", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Nevada", "Arido", "Casinò", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Nevada", "Arido", "Grattacieli", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Nevada", "Arido", "Night Life", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("Nevada", "Arido", "UFO", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("New Hampshire", "Vario", "Natura", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("New Mexico", "Arido", "Deserti", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("New Mexico", "Arido", "Natura Estrema", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("New Mexico", "Arido", "Cucina", "Montagna")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("New York", "Continentale", "Laghi", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("New York", "Continentale", "Grattacieli", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("New York", "Continentale", "Fiumi", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("New York", "Continentale", "Night Life", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("New York", "Continentale", "Cucina", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("New York", "Continentale", "Casinò", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("New York", "Continentale", "Musei", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("New York", "Continentale", "Natura", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("New Jersey", "Vario", "Grattacieli", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("New Jersey", "Vario", "Casinò", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("New Jersey", "Vario", "Night Life", "Mare")');
tx.executeSql('INSERT INTO USA(Nome,Clima,Interesse,Tipologia) VALUES ("New Jersey", "Vario", "Parchi Divertimento", "Mare")');
}
function errorCB(err) {
alert("Siamo spiacenti, c'è stato un errore di caricamento: "+err.code);
}
</script>
</head>
<body><center><img style="margin-top:13%;" width="80%" src="img/logo.png">
<br><br><br>
<a href="mare.html"><button id="start" >Trova la tua nazione!</button></a><br><br>
<a href="https://www.facebook.com/rizieri.mele"><button id="credits">Developer</button></a><br><br>
<font size="1" color="white">Copyright Rizieri Mele - 2016</font>
</center>
</body>
</html>
还有其他页面,我只添加其他两个页面(在上传的最后一页中,脚本不起作用)。
第二页
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="msapplication-tap-highlight" content="no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width" />
<!-- This is a wide open CSP declaration. To lock this down for production, see below. -->
<meta http-equiv="Content-Security-Policy" content="default-src * 'unsafe-inline'; style-src 'self' 'unsafe-inline'; media-src *" />
<!-- Good default declaration:
* gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
* https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
* Disables use of eval() and inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
* Enable inline JS: add 'unsafe-inline' to default-src
* Enable eval(): add 'unsafe-eval' to default-src
* Create your own at http://cspisawesome.com
-->
<!-- <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: 'unsafe-inline' https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *" /> -->
<link rel="stylesheet" type="text/css" href="css/base.css" />
<title>Mare</title>
<script type="text/javascript" charset="utf-8" src="js/SQLitePlugin.js"></script>
<script type="text/javascript" src="js/cordova.js"></script>
<script type="text/javascript" charset="utf-8">
function salva(){
var ris = document.getElementById("marmon");
var tris = ris.options[ris.selectedIndex].text;
localStorage.setItem("tipo",tris);
}
</script>
</head>
<body>
<center>
<div id="question"><h1><font face="Arial">Preferisci il Mare o la Montagna?</font></h1>
<select id="marmon">
<option>Mare</option>
<option>Montagna</option>
</select><br><br><br>
</div><br><br>
<a href="clima.html"><button onClick="salva()">Vai Avanti</button></a><br><br>
<font size="1" color="white">Copyright Rizieri Mele - 2016</font>
</center>
</body>
</html>
第三页
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="msapplication-tap-highlight" content="no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width" />
<!-- This is a wide open CSP declaration. To lock this down for production, see below. -->
<meta http-equiv="Content-Security-Policy" content="default-src * 'unsafe-inline'; style-src 'self' 'unsafe-inline'; media-src *" />
<!-- Good default declaration:
* gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
* https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
* Disables use of eval() and inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
* Enable inline JS: add 'unsafe-inline' to default-src
* Enable eval(): add 'unsafe-eval' to default-src
* Create your own at http://cspisawesome.com
-->
<!-- <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: 'unsafe-inline' https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *" /> -->
<link rel="stylesheet" type="text/css" href="css/base.css" />
<title>Clima</title>
<script type="text/javascript" charset="utf-8" src="js/SQLitePlugin.js"></script>
<script type="text/javascript" src="js/cordova.js"></script>
<script type="text/javascript" charset="utf-8">
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady(){
var db = window.openDatabase("ViaggioIdeale_DB", "1.0", "ViaggioIdeale", 200000);
db.transaction(queryDB);
}
function errorCB(err) {
alert("Error processing SQL: "+err.code);
}
function queryDB(tx){
var tipo = localStorage.getItem("tipo");
tx.executeSql('SELECT DISTINCT Clima FROM USA WHERE Tipologia = "'+tipo+'"',[],querySuccess,errorCB);
}
function querySuccess(tx,result){
var len = result.rows.length;
for(var i=0; i<len; i++) {
var riga = result.rows.item(i);
document.getElementById('clima').innerHTML += '<option>'+riga["Clima"]+'</option>';
}
}
function salva(){
var ris = document.getElementById("clima");
var tris = ris.options[ris.selectedIndex].text;
localStorage.setItem("clima",tris);
}
</script>
</head>
<body>
<center>
<div id="question"><h1><font face="Arial">Quale tipologia di clima preferisci?</font></h1>
<select id="clima">
</select>
<br><br><br>
</div>
<br><br>
<a href="firstinteresse.html"><button onClick="salva()">Vai Avanti</a></button><br><br>
<font size="1" color="white">Copyright Rizieri Mele - 2016</font>
</center>
</body>
</html>
荒谬的是,该脚本适用于谷歌浏览器。我试图删除数据浏览器,认为可以是这些,但没有。
PS:每次启动应用程序的数据库,它被删除并重新创建,但它是暂时的,所以我想添加一个“IF”来控制应用程序是否在之前启动。
非常感谢大家!
答案 0 :(得分:0)
Phonegap不是在浏览器中使用的技术,而是用于创建混合应用程序,因此phonegap应用程序可以在浏览器中构建,并使用本机代码来使用本机可能性。我不明白你想在浏览器中使用它,也许是为了测试,但任何数据库或本机方法都无法工作。