This version of the documentation is outdated!
Click here for the latest released version.
device.platform
獲取該設備的作業系統名稱。
var string = device.platform;
支援的平臺
- Android 系統
- 黑莓手機 WebWorks (OS 5.0 和更高)
- iOS
- Tizen
- Windows Phone 7 和 8
- Windows 8
快速的示例
// Depending on the device, a few examples are:
// - "Android"
// - "BlackBerry"
// - "iOS"
// - "WinCE"
// - "Tizen"
var devicePlatform = device.platform;
完整的示例
<!DOCTYPE html>
<html>
<head>
<title>Device Properties 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
//
document.addEventListener("deviceready", onDeviceReady, false);
// device APIs are available
//
function onDeviceReady() {
var element = document.getElementById('deviceProperties');
element.innerHTML = 'Device Model: ' + device.model + '<br />' +
'Device Cordova: ' + device.cordova + '<br />' +
'Device Platform: ' + device.platform + '<br />' +
'Device UUID: ' + device.uuid + '<br />' +
'Device Version: ' + device.version + '<br />';
}
</script>
</head>
<body>
<p id="deviceProperties">Loading device properties...</p>
</body>
</html>
黑莓手機的怪癖
設備可能會返回而不是平臺名稱的設備平臺版本編號。例如,Storm2 9550 返回一個值如2.13.0.95
.
Windows Phone 7 的怪癖
Windows Phone 7 設備報告作為平臺WinCE
.
Windows Phone 8 怪癖
Windows Phone 8 設備報告作為平臺Win32NT
.