Re: detecting flash in php
| From: | Paul Chvostek | Date: | Fri, 09 Jan 2004 05:44:01 +0000 |
| Subject: | Re: detecting flash in php | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-174091@lists.php.net to get a copy of this message | ||
On Fri, Jan 09, 2004 at 01:11:38PM +0800, Louie Miranda wrote:
>
> is there anyway of detecting flash? in php
Not really. But you're not completely out in the cold.
Note that PHP runs on the server, so any test you do has to be offloaded
to the client side. Use Javascript for this. Use MING to build your
Flash content. :)
<script type="text/javascript" language="JavaScript"><!--
FlashMode = 0;
if (navigator.plugins && navigator.plugins.length > 0) {
if (navigator.plugins["Shockwave Flash"]) {
var plugin_version = 0;
var words = navigator.plugins["Shockwave Flash"].description.split(" ");
for (var i = 0; i < words.length; ++i) {
if (isNaN(parseInt(words[i])))
continue;
plugin_version = words[i];
}
if (plugin_version >= 5) {
var plugin = navigator.plugins["Shockwave Flash"];
var numTypes = plugin.length;
for (j = 0; j < numTypes; j++) {
mimetype = plugin[j];
if (mimetype) {
if (mimetype.enabledPlugin && (mimetype.suffixes.indexOf("swf") != -1))
FlashMode = 1;
// Mac wierdness
if (navigator.mimeTypes["application/x-shockwave-flash"] == null)
FlashMode = 0;
}
}
}
}
}
if (FlashMode == 1) {
// do your flash stuff... For example:
document.write(' <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,30,0">\n');
document.write(' <param name=movie value="http://yourdomain.ca/foo.swf"><param
name=quality value=high><param name="BGCOLOR" value="#EEEEEE"><param
name="salign" value="tl"><param name="menu"
value="0">\n');
document.write(' <embed src="http://yourdomain.ca/foo.swf" quality=high
pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"
type="application/x-shockwave-flash"></embed>\n');
document.write(' </object>\n');
} else {
document.write("<p>Sorry, this page requires Flash.");
}
// --></script>
<noscript>Sorry, this page requires JavaScript</noscript>
--
Paul Chvostek <paul@it.ca>
it.canada http://www.it.ca/
Free PHP web hosting! http://www.it.ca/web/