If I develop a web app in phonegap, can the same web app be made to run in regular desktops/laptops inside a browser?
It will definitely run on desktop and on a webserver whatever, IF you do it right.
I do this with many of my apps and things to note is:
Good practice is to wrap your device specific event listeners etc. in the onDeviceReady function as:
onDeviceReady: function() {
// Register the device event listeners
document.addEventListener("backbutton", function (e) {
console.log("default prevented");
e.preventDefault();
}, false );
document.addEventListener("resume", onDeviceResume, false);
and register that in the initialize function
document.addEventListener("deviceready", onDeviceReady, false);
Apart from that I use a primitive function to assign the variable "phonegap" that I can reference if I need to know what platform we are on, or if we are desktop (in which case it will be false).
isPhoneGap: function() {
var is = false;
var agent = navigator.userAgent.toLowerCase();
var path = window.location.href;
if (path.indexOf("file://") != -1) {
if (agent.indexOf("android") != -1) {
is = "android";
} else if (agent.indexOf("iphone") != -1 || agent.indexOf("ipad") != -1 || agent.indexOf("ipod") != -1) {
is = "ios";
} else if (agent.indexOf("iemobile") != -1) {
is = "wp";
}
}
return is;
},
Not super pretty but hope this helps.