Quick Ripple Tip - Detecting Ripple

This post is more than 2 years old.

This was asked on the Ripple development listserv:

For debugging purposes, I'd like to do different things when I am using ripple, than when I am running Phonegap on my phone. Is there an easy way to tell, if I am in Ripple?

Gord Tanner replied that you can look for window.parent.ripple. He said he hadn't tested it but I ran a quick test and it worked fine (it existed in Ripple and did not exist in the iOS simulator).

In general writing code like this concerns me as it smells like the type of thing you can forget to remove in production, but we've all done stuff like this before (including myself) so there ya go. ;)

By the way, information about how to sign up for the mailing list can be found here: http://ripple.incubator.apache.org/#mailinglist.

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Archived Comments

Comment 1 by Val posted on 1/22/2014 at 11:24 PM

The script that Ripple itself injects into pages is checking it like this:
if (window.top.ripple) { ... }

The other way to check if Ripple if there, which is rather funny:
if (window.tinyHippos) { ... }