By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,267 Members | 1,861 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,267 IT Pros & Developers. It's quick & easy.

A question on Firefox

P: n/a

Hello group,

I'm kinda skeptical about a code is being used in my js program. All it
does is checking what browser is being run and finds out if FLASH is
installed or not.

This code works just fine withe IE but as far as Firefox I'm not sure.
Using the firefox I can see flash pages easily but when this code says
firefox is not installed in my firefox!!!

Any suggestions?

Please know that I have another machine with firefox (without flash)
and the code reacts fine.

Thanks in advance,
Amit.

Jul 27 '06 #1
Share this Question
Share on Google+
12 Replies


P: n/a
amit said the following on 7/27/2006 5:35 PM:
Hello group,

I'm kinda skeptical about a code is being used in my js program. All it
does is checking what browser is being run and finds out if FLASH is
installed or not.
"checking what browser is being run"? Yes, you should be very skeptical
about it.
This code works just fine withe IE but as far as Firefox I'm not sure.
I bet it doesn't.
Using the firefox I can see flash pages easily but when this code says
firefox is not installed in my firefox!!!
"firefox is not installed in your firefox"? I wanna know how to do that
so that I can have my firefox installed in my firefox.
Any suggestions?
Ummm, perhaps posting your browser detection and Flash detection code?
Please know that I have another machine with firefox (without flash)
and the code reacts fine.
I bet it doesn't, you just think it does. But, I wouldn't know because I
can't see the code.....

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 27 '06 #2

P: n/a

Randy Webb wrote:
amit said the following on 7/27/2006 5:35 PM:
Hello group,

I'm kinda skeptical about a code is being used in my js program. All it
does is checking what browser is being run and finds out if FLASH is
installed or not.

"checking what browser is being run"? Yes, you should be very skeptical
about it.
This code works just fine withe IE but as far as Firefox I'm not sure.

I bet it doesn't.
Using the firefox I can see flash pages easily but when this code says
firefox is not installed in my firefox!!!

"firefox is not installed in your firefox"? I wanna know how to do that
so that I can have my firefox installed in my firefox.
Any suggestions?

Ummm, perhaps posting your browser detection and Flash detection code?
Please know that I have another machine with firefox (without flash)
and the code reacts fine.

I bet it doesn't, you just think it does. But, I wouldn't know because I
can't see the code.....

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

Hi Randy,

Thanks! here is the code:

IEFlashStat = ((navigator.appName.indexOf("Microsoft") != -1) &&
(navigator.appVersion.indexOf("Windows") !=
-1))&&
(parseFloat(navigator.appVersion) >= 4 ) ? true
: false;
if (IEFlashStat )
{
alert("IE and flash OK");
//Ok, the browser detected as IE4 or 4+; ready for
Flash events
_bFlash = true;
}
else
{
//The browser is not IE so check if we are dealing with
NN or FF
NNFlashStat = ((navigator.appName == "Netscapt") &&
(navigator.userAgent.indexOf("Mozilla") != -1))
? ture : false;

if (NNFlashStat)
{
alert("yep, Flash in FF or NN");
_bFlash = true;
}
else
{
_bFlash = false;
alert("no flash in your FF or NN");
}
}

Please let me know what you think of it.

Thanks for being helpful.
one more thing when I use macros or predefined variable in Javascript
it has difficulty why is that?

let's say at the top of the code I have:

var ms = "Microsoft";
navigator.appName.indexOf(ms)

will not work. why?
Amit.

Jul 27 '06 #3

P: n/a
Well, just browsing quickly I found this already...

NNFlashStat = ((navigator.appName == "Netscapt") &&

Since when has there been a browser called "Netscapt"? You may wish to
prrof read more...

"amit" <am********@gmail.comwrote in message
news:11**********************@s13g2000cwa.googlegr oups.com...
>
Randy Webb wrote:
>amit said the following on 7/27/2006 5:35 PM:
Hello group,

I'm kinda skeptical about a code is being used in my js program. All it
does is checking what browser is being run and finds out if FLASH is
installed or not.

"checking what browser is being run"? Yes, you should be very skeptical
about it.
This code works just fine withe IE but as far as Firefox I'm not sure.

I bet it doesn't.
Using the firefox I can see flash pages easily but when this code says
firefox is not installed in my firefox!!!

"firefox is not installed in your firefox"? I wanna know how to do that
so that I can have my firefox installed in my firefox.
Any suggestions?

Ummm, perhaps posting your browser detection and Flash detection code?
Please know that I have another machine with firefox (without flash)
and the code reacts fine.

I bet it doesn't, you just think it does. But, I wouldn't know because I
can't see the code.....

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices -
http://www.JavascriptToolbox.com/bestpractices/


Hi Randy,

Thanks! here is the code:

IEFlashStat = ((navigator.appName.indexOf("Microsoft") != -1) &&
(navigator.appVersion.indexOf("Windows") !=
-1))&&
(parseFloat(navigator.appVersion) >= 4 ) ? true
: false;
if (IEFlashStat )
{
alert("IE and flash OK");
//Ok, the browser detected as IE4 or 4+; ready for
Flash events
_bFlash = true;
}
else
{
//The browser is not IE so check if we are dealing with
NN or FF
NNFlashStat = ((navigator.appName == "Netscapt") &&
(navigator.userAgent.indexOf("Mozilla") != -1))
? ture : false;

if (NNFlashStat)
{
alert("yep, Flash in FF or NN");
_bFlash = true;
}
else
{
_bFlash = false;
alert("no flash in your FF or NN");
}
}

Please let me know what you think of it.

Thanks for being helpful.
one more thing when I use macros or predefined variable in Javascript
it has difficulty why is that?

let's say at the top of the code I have:

var ms = "Microsoft";
navigator.appName.indexOf(ms)

will not work. why?
Amit.

Jul 27 '06 #4

P: n/a
Hmm - prrof? PROOF... Perhaps I should too!

"PSI_Orion" <or***@psiss.comwrote in message
news:_v****************@newsfe3-win.ntli.net...
Well, just browsing quickly I found this already...

NNFlashStat = ((navigator.appName == "Netscapt") &&

Since when has there been a browser called "Netscapt"? You may wish to
prrof read more...

"amit" <am********@gmail.comwrote in message
news:11**********************@s13g2000cwa.googlegr oups.com...
>>
Randy Webb wrote:
>>amit said the following on 7/27/2006 5:35 PM:
Hello group,

I'm kinda skeptical about a code is being used in my js program. All
it
does is checking what browser is being run and finds out if FLASH is
installed or not.

"checking what browser is being run"? Yes, you should be very skeptical
about it.

This code works just fine withe IE but as far as Firefox I'm not sure.

I bet it doesn't.

Using the firefox I can see flash pages easily but when this code says
firefox is not installed in my firefox!!!

"firefox is not installed in your firefox"? I wanna know how to do that
so that I can have my firefox installed in my firefox.

Any suggestions?

Ummm, perhaps posting your browser detection and Flash detection code?

Please know that I have another machine with firefox (without flash)
and the code reacts fine.

I bet it doesn't, you just think it does. But, I wouldn't know because I
can't see the code.....

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices -
http://www.JavascriptToolbox.com/bestpractices/


Hi Randy,

Thanks! here is the code:

IEFlashStat = ((navigator.appName.indexOf("Microsoft") != -1) &&
(navigator.appVersion.indexOf("Windows") !=
-1))&&
(parseFloat(navigator.appVersion) >= 4 ) ? true
: false;
if (IEFlashStat )
{
alert("IE and flash OK");
//Ok, the browser detected as IE4 or 4+; ready for
Flash events
_bFlash = true;
}
else
{
//The browser is not IE so check if we are dealing with
NN or FF
NNFlashStat = ((navigator.appName == "Netscapt") &&
(navigator.userAgent.indexOf("Mozilla") != -1))
? ture : false;

if (NNFlashStat)
{
alert("yep, Flash in FF or NN");
_bFlash = true;
}
else
{
_bFlash = false;
alert("no flash in your FF or NN");
}
}

Please let me know what you think of it.

Thanks for being helpful.
one more thing when I use macros or predefined variable in Javascript
it has difficulty why is that?

let's say at the top of the code I have:

var ms = "Microsoft";
navigator.appName.indexOf(ms)

will not work. why?
Amit.


Jul 27 '06 #5

P: n/a

PSI_Orion wrote:
Hmm - prrof? PROOF... Perhaps I should too!

"PSI_Orion" <or***@psiss.comwrote in message
news:_v****************@newsfe3-win.ntli.net...
Well, just browsing quickly I found this already...

NNFlashStat = ((navigator.appName == "Netscapt") &&

Since when has there been a browser called "Netscapt"? You may wish to
prrof read more...

"amit" <am********@gmail.comwrote in message
news:11**********************@s13g2000cwa.googlegr oups.com...
>
Randy Webb wrote:
amit said the following on 7/27/2006 5:35 PM:
Hello group,

I'm kinda skeptical about a code is being used in my js program. All
it
does is checking what browser is being run and finds out if FLASH is
installed or not.

"checking what browser is being run"? Yes, you should be very skeptical
about it.

This code works just fine withe IE but as far as Firefox I'm not sure.

I bet it doesn't.

Using the firefox I can see flash pages easily but when this code says
firefox is not installed in my firefox!!!

"firefox is not installed in your firefox"? I wanna know how to do that
so that I can have my firefox installed in my firefox.

Any suggestions?

Ummm, perhaps posting your browser detection and Flash detection code?

Please know that I have another machine with firefox (without flash)
and the code reacts fine.

I bet it doesn't, you just think it does. But, I wouldn't know because I
can't see the code.....

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices -
http://www.JavascriptToolbox.com/bestpractices/
Hi Randy,

Thanks! here is the code:

IEFlashStat = ((navigator.appName.indexOf("Microsoft") != -1) &&
(navigator.appVersion.indexOf("Windows") !=
-1))&&
(parseFloat(navigator.appVersion) >= 4 ) ? true
: false;
if (IEFlashStat )
{
alert("IE and flash OK");
//Ok, the browser detected as IE4 or 4+; ready for
Flash events
_bFlash = true;
}
else
{
//The browser is not IE so check if we are dealing with
NN or FF
NNFlashStat = ((navigator.appName == "Netscapt") &&
(navigator.userAgent.indexOf("Mozilla") != -1))
? ture : false;

if (NNFlashStat)
{
alert("yep, Flash in FF or NN");
_bFlash = true;
}
else
{
_bFlash = false;
alert("no flash in your FF or NN");
}
}

Please let me know what you think of it.

Thanks for being helpful.
one more thing when I use macros or predefined variable in Javascript
it has difficulty why is that?

let's say at the top of the code I have:

var ms = "Microsoft";
navigator.appName.indexOf(ms)

will not work. why?
Amit.
oh! thanks for your review and help!

Jul 27 '06 #6

P: n/a
amit wrote:
Randy Webb wrote:
amit said the following on 7/27/2006 5:35 PM:
Hello group,
>
I'm kinda skeptical about a code is being used in my js program. All it
does is checking what browser is being run and finds out if FLASH is
installed or not.
It does the first unreliably and doesn't do the second at all. Please
read about browser detection, it is utterly unreliable.
[...]
>
IEFlashStat = ((navigator.appName.indexOf("Microsoft") != -1) &&
(navigator.appVersion.indexOf("Windows") !=
-1))&&
(parseFloat(navigator.appVersion) >= 4 ) ? true
: false;
Your test is equivalent to:

IEFlashStat = (true)? true : false;
Consider:

IEFlashStat = navigator.appName.indexOf("Microsoft") != -1
&& navigator.appVersion.indexOf("Windows") != -1
&& parseFloat(navigator.appVersion) >= 4;

if (IEFlashStat )
{
alert("IE and flash OK");
//Ok, the browser detected as IE4 or 4+; ready for
Flash events
_bFlash = true;
If the tests above returned true, how does that prove that the browser
is IE? Or that Flash is installed? And why not set _bFlash in the
first place, why store the result in IEFlashStat then copy it to
_bFlash?

}
else
{
//The browser is not IE so check if we are dealing with
NN or FF
NNFlashStat = ((navigator.appName == "Netscapt") &&
(navigator.userAgent.indexOf("Mozilla") != -1))
? ture : false;
Supposing you fix the "Netscapt" typo, the value of NNFlashStat will be
"ture".

if (NNFlashStat)
Which neatly type-converts here to boolean true. Compensating errors -
clever! If you ditch the unnecessary test to see if true is true, you
remove the possiblity of making that typo altogether.

{
alert("yep, Flash in FF or NN");
_bFlash = true;
So how did that prove that Flash was installed? Even if it detected
Flash reliably (and it absolutely doesn't), how do you know the user
isn't blocking Flash content? e.g. using Firefox and Flashblock.

The bottom line is, your "detection" is useless. Assume that some of
your visitors can't see your Flash stuff and that you have no way of
knowing which ones they are.

[...]
one more thing when I use macros or predefined variable in Javascript
it has difficulty why is that?

let's say at the top of the code I have:

var ms = "Microsoft";
navigator.appName.indexOf(ms)

will not work. why?
What is your definition of 'work'?

You have initialised a global variable with a value of the string
"Microsoft". You then test to see whether that string exists within
the string returned by navigator.appName. You don't do anything with
the result, it vanishes into the ether - unused, unloved and
unlamented.

--
Rob

Jul 28 '06 #7

P: n/a
RobG said the following on 7/27/2006 9:01 PM:
amit wrote:
<snip>

> else
{
//The browser is not IE so check if we are dealing with
NN or FF
NNFlashStat = ((navigator.appName == "Netscapt") &&
(navigator.userAgent.indexOf("Mozilla") != -1))
? ture : false;

Supposing you fix the "Netscapt" typo, the value of NNFlashStat will be
"ture".
Actually, it would be undefined since ture is not quoted. Since there is
no variable named ture anywhere, it would result in it being undefined.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 28 '06 #8

P: n/a
Randy Webb a écrit :
"firefox is not installed in your firefox"? I wanna know how to do that
so that I can have my firefox installed in my firefox.
chrome://browser/content/browser.xul

--
laurent
Jul 28 '06 #9

P: n/a
amit <am********@gmail.comwrote:
I'm kinda skeptical about a code is being used in my js program. All it
does is checking what browser is being run and finds out if FLASH is
installed or not.
Generally, best practice code does not rely on browser detection.
There are innumerable browsers in existence and use, most of which you
have probably not thought of; for example, early versions of
Firefox/Firebird identify with fanciful names such as "Fireoyster".
More typically, you have failed to consider the significant number of
users who will be using Konqueror, Galeon, Opera or Lynx. Rather than

if( browser_is_IE )
...
else if( browser_is_Firefox )
...

, prefer

if( object.feature )
use_it();
else if( another_object.outdatedFeature )
use_it_instead();
else if( some.really.old.feature )
try_that();

This has the further advantage of not being caught short by the
non-zero number of users still using dead IE versions with primitive
script support; believe it or not, there are Netscape 4 and IE 4 users
out there.

--
C. Benson Manica | I *should* know what I'm talking about - if I
cbmanica(at)gmail.com | don't, I need to know. Flames welcome.
Jul 28 '06 #10

P: n/a
Christopher Benson-Manica said the following on 7/27/2006 10:23 PM:
amit <am********@gmail.comwrote:
>I'm kinda skeptical about a code is being used in my js program. All it
does is checking what browser is being run and finds out if FLASH is
installed or not.

Generally, best practice code does not rely on browser detection.
One small correction. "best practice code" *never* relies on browser
detection, *ever*.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 28 '06 #11

P: n/a
Laurent Vilday said the following on 7/27/2006 9:35 PM:
Randy Webb a écrit :
>"firefox is not installed in your firefox"? I wanna know how to do
that so that I can have my firefox installed in my firefox.

chrome://browser/content/browser.xul

Weal Ile be dammed if dat aint kewel.

Not sure what I would ever want to use that for but it's still neat.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 28 '06 #12

P: n/a

Randy Webb wrote:
Christopher Benson-Manica said the following on 7/27/2006 10:23 PM:
amit <am********@gmail.comwrote:
I'm kinda skeptical about a code is being used in my js program. All it
does is checking what browser is being run and finds out if FLASH is
installed or not.
Generally, best practice code does not rely on browser detection.

One small correction. "best practice code" *never* relies on browser
detection, *ever*.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

Thanks to you all,

I started Javascript 2 months ago that is why I keep posting my
questions on here and of course there are so many experts in this group
that come up with good solutions as you guys did here but in the case
it seems there is no way to detect Flash in a browser.

Right?

Also, here my concern was detecting only IE and FF since most of the
users use IE or FF these days but yes you are right there are so many
browsers up there that makes it hard to conver all those things.

Regarding macro or pre defined variables I must say since I'm coming
from a C programming background so I was expecting to use the same
habit here but it looks it is not going to work.

Once again thanks for your help and looking forward to hear more advice
from you guys.

Amit.

Jul 28 '06 #13

This discussion thread is closed

Replies have been disabled for this discussion.