Two out of four is bad.

Sep 09, 2012

I am executing a simple if-then javascript statement that goes like this :

var player = GetPlayer();
if( navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/iPad/i) )
{var isipad = true;}
else
{var isipad = false;}
player.SetVar("isipad",isipad);

The initial value of the 'isipad' variable is set to True.

Out of the 4 devices, iPad and IE (of all things) return the right boolean value (true for iPad, false for IE).

However, the latest versions of Firefox and Chrome both also return true for some reason.

I also made a test script that only changed the initial value of a variable to something else, in order to test this and it also yielded the same results in those browsers.

Has anyone come across this before? Can anyone confirm this is a bug? Is there any alternative?

Any input would be appreciated.

Alex

2 Replies
Alexandros Anoyatis

Actually solved it by just changing the initial value of the variable 'isipad' to false.

But it is remarkable to know that i had to rely on pure circumstance to achieve this simple "calculation".

As I said before, I was astounded with the inability of the current versions of Firefox and Chrome to handle even the simplest of scripts.

For example : Variable 'test' has initial value of 'false'.

var player = GetPlayer();
var test = true;
player.SetVar("test",test);

Both Firefox and Chrome still report false...

Shaking my head...

Steve Flowers

Odd behavior Alexandros. 

The way I've swung this, pretty consistently, is by setting a variable iOS to true by default. Using a JavaScript trigger, I set it to false to differentiate the presentation.

var player=GetPlayer();

player.SetVar("iOS",false);

Has worked fine for me on both Chrome and Firefox. Make sure the Flash Security Settings are set to allow your folder if you're running locally.

Steve

This discussion is closed. You can start a new discussion or contact Articulate Support.