Is there a way to detect, that my application is currently running on the Ripple Emulator, instead of a real device? I want some workaround code to be ran only on the emulator.
-
I have created a small JS routine, based on a chozen reply: `function isOnRippleEmulator() { if (navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry|IEMobile)/)) { return false; } else { return true; } }` – Vladius May 07 '15 at 16:32
2 Answers
you can check if a ripple instance is aviable:
if(typeof window.parent.ripple ==="undefined")
if ripple is a object, ripple is running otherweise ripple is not running! Quick and easy.
try to explain:
The target app runs in an iframe. If a ripple session has started is an object named "ripple" instantiated (at this point it does not matter what makes the object "ripple"). It's enough just to know that the object has been created. Because with this knowledge, we know that the app runs in a ripple container.
With window.parent
we can query the parent node of a iframe, in this case, the ripple environment in which there is also the ripple object.

- 370
- 4
- 9
You need to check the userAgent
property in navigator
object and check for a ripple instance on your DOM with window.parent.ripple
. Ripple-Emulator is a browser
userAgent. Maybe you going to add firefoxOS. :)
Hint: This is not a direct case of ripple emulator. It allows to detect browser or mobile device in JavaScript.
//check if the application is running on a mobile device or desktop
if (navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry|IEMobile)/)
&& !window.parent.ripple) {
app.deviceType = 'mobile';
} else {
app.deviceType = 'browser';
}
-
Thanks a lot! That actually works. I have created a routine based on this. – Vladius Jul 23 '14 at 19:14
-
Doesn't work as my Ripple userAgent is: `"Mozilla/5.0 (Linux; U; Android 2.3.2; en-us; Nexus S Build/GRH78C) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"` – Marek Apr 12 '17 at 10:08
-
@MarekCzaplicki thanks for the downvote so. It did work fine in the past but it seems like ripple has changed. I updated my answer so it should work for you. – lin Apr 12 '17 at 10:15
-