Last active
August 29, 2015 14:05
-
-
Save videlais/9c66c56655e8a8cac39c to your computer and use it in GitHub Desktop.
Detecting Apache Cordova
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Device Ready Example</title> | |
<script type="text/javascript" charset="utf-8" src="cordova.js"></script> | |
<script type="text/javascript" charset="utf-8"> | |
// Wait for device API libraries to load | |
// | |
function onLoad() { | |
document.addEventListener("deviceready", onDeviceReady, false); | |
} | |
// device APIs are available | |
// | |
function onDeviceReady() { | |
// Now safe to use device APIs | |
} | |
</script> | |
</head> | |
<body onload="onLoad()"> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Device Ready Example</title> | |
<script type="text/javascript" charset="utf-8" src="cordova.js"></script> | |
<script type="text/javascript" charset="utf-8"> | |
var isCordovaApp = (typeof window.cordova !== "undefined"); | |
if(isCordovaApp) { | |
document.addEventListener("deviceready", loadProject, false); | |
} else { | |
loadProject(); | |
} | |
function loadProject() { | |
//Load project code here. | |
} | |
</script> | |
</head> | |
<body> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var isCordovaApp = (document.location.protocol === "file:"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var isCordovaApp = (document.URL.indexOf('http://') === -1 && document.URL.indexOf('https://') === -1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var isCordovaApp = (typeof window.cordova !== "undefined"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment