Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 338
  • Last Modified:

Flash detection script isn't working.

I've got the following code posted on http://216.167.122.202/index_flash.asp.  The purpose of it is to display a flash banner if the client has flash, and a randomized graphic if the client does not have flash.  For some reason it's not working.  For easy reference, the rest of the code is here: http://216.167.122.202/flash_detect.js


<script type="text/javascript" src="flash_detect.js">
function getFlashVersion() { return null; };

var requiredVersion = 5
var r = ((Math.ceil(Math.random() * 6))-1)
var flashVersion = getFlashVersion()
           
if (flashVersion >= requiredVersion) {
      document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="750" height="235"><param name="movie" value="images/banner_home.swf"><param name="quality" value="high"><embed src="images/banner_home.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="750" height="235"></embed></object>')
}
else if (flashVersion == 0 || flashVersion == flashVersion_DONTKNOW || flashVersion == null) {
      document.write('<img src="images/bannerhome/' + r + '.jpg" height="235" width="750">')
}
0
Severisth
Asked:
Severisth
  • 3
1 Solution
 
devicCommented:
<script>
/*devic's method*/
function getFlashVer()
{
      for(var i=10; i>0; i--)
      {
            try
            {
                  var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i);
                  return i;
            }
            catch(e){}
      }
      return 0;
}
alert(getFlashVer());
</script>
0
 
SeveristhAuthor Commented:
What browsers does your script work with, Devic?
0
 
devicCommented:
Severisth,
I have flash installed only on IE, but I believe it will work almost on all browsers.
0
 
badrulnmCommented:
Severisth,
>> function getFlashVersion() { return null; };

You should remove the above line from your html file because it override the working function in the flash_detect.js file that you load with <script type="text/javascript" src="flash_detect.js">.


devic,
>> var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i);

that only works on IE.

0
 
devicCommented:
SP1 :)
for netscape:
=============
      if (navigator.plugins)
      {
            for(var i=0;i<navigator.plugins.length;i++)
            {
                  if(navigator.plugins[i].name.match(/Flash/i))
                  {
                        return navigator.plugins[i].description.match(/Flash ([\d])/)[1];
                  }
            }
      }
=================================
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now