Detect browser/mobile platform in onDeviceReady event or somewhere else

Try to detect Browser/Mobile platform in onDeviceReady event

I used this code in a js file

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
window.dtype = device.platform;

And startScreen Load JS console.log(window.dtype) but is always undefined
I thought it's only works on real mobile devices.
Changed code to this one

if (navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry|IEMobile)/)) {
document.addEventListener("deviceready", onDeviceReady, false);
window.dtype = "app";
} else {
onDeviceReady(); //this is the browser
window.dtype = "browser";

dtype undefined too, tried code in startScreen Device Ready event JS, same result, in Load JS shows dtype undefined.

How can detect browser/device platform?
1 person has
this question
This topic is no longer open for comments or replies.