cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Filip Maj <>
Subject Re: Determining if "you're in cordova"
Date Tue, 04 Dec 2012 01:06:30 GMT
But look at that situation from the browser's POV: it attaches to an event
that never fires. 

cordova.js is included and window.cordova exists, but in a browser's
context, it does nothing.

On 12/3/12 5:03 PM, "Anis KADRI" <> wrote:

>document.addEventListener('deviceready', function() {navigator.inCordova =
>true;}, false);
>If you fire 'deviceready' yourself then you already know that you're not
>a cordova app context. Don't you ?
>Sorry, I really don't see what the problem is. Maybe an real world example
>would help illustrate it. Or is there a reason why you don't want to use
>deviceready as an indicator ?
>On Mon, Dec 3, 2012 at 4:40 PM, Max Ogden <> wrote:
>> if cordova polyfilled standard apis for everything it wouldn't be
>> problem. but right now there are only-in-cordova APIs that I need to
>>use if
>> i'm in cordova. it would be more convenient for me as an app developer
>> there was a supported way to know i'm in cordova.
>> I can keep looking at window.location.href and make sure to always run a
>> local web server for development (and never open the file directly on my
>> dev machine) but the point here is that doing those things is more
>> prone and less user friendly for new devs than doing "if
>> (navigator.inCordova)".
>> if its a ton of work to implement then I can understand not doing it (I
>> dont know what it would take to implement). i'm just trying to say it
>> be a nicer api :) it seems from my perspective that it would be easy for
>> cordova to tell the browser that cordova is present and it would save
>> developers from having to use yet another hacky technique.

View raw message