Am 26.11.2006 um 21:04 schrieb Philip Roy <email@hidden>:
Hi all,
I've been trying to get some help for a piece of JavaScript in a
web page
(actually it will be used as part of a Mac widget) that will detect
if a
user as the Flip4Mac (www.flip4Mac) QT plugin installed on their
machine.
I don't think it's possible to test for the presence of Quicktime
plugins. (At least not the way you are trying to.) You can test for
browser plugins though. (They are completely different things.
Flip4Mac can install the QT plugin without installing the browser
plugin for example.)
I've been posting in the developer area of the Flip4Mac discussion
site, but
after two months there hasn't really been a solution. I wouldn't have
thought it was hard, but I'm no coder, so I'm turning to this list
for help.
This was the last suggestion for code....
//
function checkPlayer() {
for (i = 0; i < navigator.plugins.length; i++) {
if (navigator.plugins.name.indexOf("Flip4Mac") != -1 &&
navigator.plugins.name.indexOf("Plug") != -1) {
//alert(navigator.plugins.filename);
hasPlugIn = true;
alert("Flip4Mac found");
} else {
alert("No Flip4Mac");
}
}
}
But in testing, I get an "undefined value" error on this line....
if (navigator.plugins.name.indexOf("Flip4Mac") != -1 &&
navigator.plugins.name.indexOf("Plug") != -1) {
That's not really surprising.
First you are iterating through the list of plugins using the index
variable i. This index is not used inside your loop at all which
makes the loop kind of pointless.
Second, you are using the indexOf() method on the name property of an
array, not on the name property of each element of the array. That
makes no sense at all and is probably the cause of your undefined
value error. An array doesn't have a name property.
Third the actual test does not make sense either. You are apparently
testing for name == "Flip4Mac" AND name == "Plug" ??? Both can never
happen at once so the test would always result in false.
Fourth the variable hasPlugIn is neither declared nor initialized.
Since it's not used it doesn't make any difference but it's pretty
useless this way.
Fifth it's a good idea to declare index variables like i with var i
since otherwise they become global in scope. That might lead to
subtle problems later on. The same goes for hasPlugIn but in this
case the global scope might be intentional.
I don't know the proper way to identify the Flip4Mac plugin but
assuming its name is always "Flip4Mac" then something like this
should work (typed in Mail.app, not tested):
function checkPlayer()
{
var hasPlugIn = false;
for (var i = 0;i < navigator.plugins.length;i++)
{
if (navigator.plugins[i].name == "Flip4Mac")
{
hasPlugIn = true;
break;
}
}
if (hasPlugIn)
alert("Flip4Mac found");
else
alert("No Flip4Mac");
}
And a more general question: Why do you need to test for the presence
of a specific browser plugin? This will work on modern Mac OS X
browsers only at best. So you are building something very specific
here. I could see the need to figure out if the browser supports a
certain media type but how that is achieved, through some plugin or
natively, should not really matter. You might therefore change your
test to if (navigator.mimeTypes["video/wmv"]) or some something
similar. (The example media type "video/wmv" would need to be
replaced by a real media type since I haven't checked if it actually
exists.)
From a user perspective I hate it when websites think they are
smarter than I by incorrectly assuming that if I don't have a browser
plugin for some media type I can't download and view the media. A
number of sites want to force me to install the browser plugin which
I often don't want to do. The nice thing to do would be to offer a
download of the file instead.
HTH
Mike
--
Mike Fischer Softwareentwicklung, EDV-Beratung
Schulung, Vertrieb
Web: <http://homepage.mac.com/mike_fischer/index.html>
Note: I read this list in digest mode!
Send me a private copy for faster responses.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Web-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/web-dev/email@hidden