मैं एम्बेडेड स्कैनर के साथ मोबाइल डिवाइस के साथ काम कर रहा हूं। विभिन्न उपकरणों की कुछ जावास्क्रिप्ट लाइब्रेरी का उपयोग करने और विभिन्न निर्माता (ज़ेबरा, हनीवेल, डेलिटलिक, आईओएस ect ...) के उन पुस्तकालयों के साथ संघर्ष से बचने में सक्षम होने के लिए मुझे प्रत्येक डिवाइस की पहचान करने के लिए एक तरीके से आने की आवश्यकता है ताकि मैं कर सकूं उचित पुस्तकालय लोड करें और यही वह है जिसके साथ मैं आया था।
getDeviceName: function() {
var deviceName = '';
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
Datalogic: function() {
return navigator.userAgent.match(/DL-AXIS/i);
},
Bluebird: function() {
return navigator.userAgent.match(/EF500/i);
},
Honeywell: function() {
return navigator.userAgent.match(/CT50/i);
},
Zebra: function() {
return navigator.userAgent.match(/TC70|TC55/i);
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
Windows: function() {
return navigator.userAgent.match(/IEMobile/i);
},
any: function() {
return (isMobile.Datalogic() || isMobile.Bluebird() || isMobile.Honeywell() || isMobile.Zebra() || isMobile.BlackBerry() || isMobile.Android() || isMobile.iOS() || isMobile.Windows());
}
};
if (isMobile.Datalogic())
deviceName = 'Datalogic';
else if (isMobile.Bluebird())
deviceName = 'Bluebird';
else if (isMobile.Honeywell())
deviceName = 'Honeywell';
else if (isMobile.Zebra())
deviceName = 'Zebra';
else if (isMobile.BlackBerry())
deviceName = 'BlackBerry';
else if (isMobile.iOS())
deviceName = 'iOS';
else if ((deviceName == '') && (isMobile.Android()))
deviceName = 'Android';
else if ((deviceName == '') && (isMobile.Windows()))
deviceName = 'Windows';
if (deviceName != '') {
consoleLog('Devices information deviceName = ' + deviceName);
consoleLog('Devices information any = ' + isMobile.any());
consoleLog('navigator.userAgent = ' + navigator.userAgent);
}
return deviceName;
},
आनंद लें और इस यह कैसे इस्तेमाल किया जा सकता का एक उदाहरण है:
initializeHandheldScanners: function() {
if (DeviceCtrl.getDeviceName() == 'Zebra')
DeviceCtrl.initializeSymbolScanner();
if (DeviceCtrl.getDeviceName() == 'Honeywell')
DeviceCtrl.initializeHoneywellScanner();
if (DeviceCtrl.getDeviceName() == 'Datalogic')
DeviceCtrl.initializeDatalogicScanner();
},
आप कोरी LaViska करने के लिए धन्यवाद कह सकते हैं। मैंने यह उनके काम के आधार पर किया था। यहाँ लिंक अगर आप जानना चाहते हैं और अधिक
https://www.abeautifulsite.net/detecting-mobile-devices-with-javascript
जो ब्राउज़र मोबाइल डिवाइस चल रहा है पर निर्भर करता है, लेकिन आप को पता है कि यह एक iPhone या Android डिवाइस या जो नाम ठीक वैसे ही आप की जरूरत है चाहता हूँ है? –
केवल एक चीज जो आप प्राप्त कर सकते हैं वह है उपयोगकर्ता-एजेंट –
यहां 'WURFL.js' का उपयोग करने का एक लिंक है, यह मुफ़्त है http://www.smashingmagazine.com/2014/07/01/server-side-device-detection- जावास्क्रिप्ट/ – Pierre