App running environment

can i detect the app running environment? ie windows browser, android or ios

i have use phonegap device plugin. it is always prompt for uncaught referenceerror, device is not defined when i test run in google chrome browser. i have use
if device=undefined then , but still not working

Thanks
Teo

If (navigator.userAgent.match(/(ios|iPhone|iPod|iPad)/)) Then
  NSB.Msgbox("iOS")
Else If (navigator.userAgent.match(/(Windows)/)) Then
  NSB.Msgbox("Windows")
Else If (navigator.userAgent.match(/(Android)/)) Then 
  NSB.Msgbox("Android")
Else
  NSB.Msgbox("Unknown")
end if

For Chrome, I use this cordova-emulator: https://github.com/yporqueno/cordova-emulator