• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 257
  • Last Modified:

Flash auto detection

Hi!

I just started to use Flash and I'ld really like to find out how you can  build a website that autodetects if you have Flash installed - if yes, load Flash animation, if no, possibility to download Flash.
I've tried the built-in option in Flash (with publication settings) but the results weren't quite satisfactory.

Thanx.
0
Yogey
Asked:
Yogey
  • 3
  • 2
  • 2
  • +1
1 Solution
 
SuperMarioCommented:
Here's the code from hydrarig.com (my favorite reference site for Flash detection, made by me)

Open up your HTML page that has the Flash in it and find the tag that says <HEAD>. If there is no <HEAD> tag, add everything below between a <HEAD> and </HEAD> tag... however you do it, the code below must be between a <HEAD> and </HEAD> tag.

<SCRIPT>
<!--
function validateFlash()
{
      browser = navigator.appName;
      ver = parseInt(navigator.appVersion);
      var hasPlugin;
      if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) {
      if (navigator.plugins && navigator.plugins["Shockwave Flash"])
            hasPlugin = 1;
      }

      if((browser = "Microsoft Internet Explorer" && ver >= 4) || (hasPlugin == 1))
      {
            self.navigate("FrameFlash.html");
      }
      else
      {
            self.navigate("noflash.html");
      }
}
//-->
</SCRIPT>

Then find your <BODY> tag. It should either just say <BODY> or have a bunch of attributes like <BODY BGCOLOR="blah"> etc.

Add an attribute so that your body tag looks like

<BODY onLoad="setTimeout('validateFlash()', 1000">

Leave any other attributes in there but add the onLoad attribute.

This will cause your page to detect Flash via javascript.

If you need more help lemme know =)

-Dan
0
 
YogeyAuthor Commented:
Your code works excellent in Explorer but causes a javascript error in Netscape. I found out it has something to do with the "self.navigate" portion. Do you know a solution for this?
0
 
YogeyAuthor Commented:
Your code works excellent in Explorer but causes a javascript error in Netscape. I found out it has something to do with the "self.navigate" portion. Do you know a solution for this?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
SuperMarioCommented:
Hmm. I have been told this before also.

Does it give you the same problem if you change it to navigateURL instead of navigate?

Give that a shot =)

-D

0
 
burntoutCommented:
This is what it says to do at macromedia.com (Creaters of Flash)

You should make a new animation that is
18x18 with 2 frames, on the second frame you add a GetURL Action and set it to the "Flash Page" this way the only way they will get redirected to this page is if they have flash. you place this animation on the first page of your site, you also add a meta refresh that will redirect the user in (10 seconds says macromedia but I use 5) this way if the movie does not load and redirect the user in less then 10 seconds they will be redirected to the "Noflash page" Here is a link to the actual macromedia page with this info.
http://macromedia.com/support/flash/ts/documents/scriptfree_detection.htm

I use this and it works great.. if you want to see my site is at...
http://www.323tech.com

good luck!
0
 
coopaCommented:
Have a look at www.assembly-line.co.uk, I have a page that not only detects the flash version, but then tells the user what version they have.  

It then forwards them on to a flash 4 version if they have flash 4 or a text version if they have any other version of flash or no flash at all.

This works in NSN and IE browsers.

----------------------------------

 <SCRIPT LANGUAGE="JavaScript">
flashver=0

var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] ?
      navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0);
if (plugin && parseInt(plugin.description.substring(plugin.description.indexOf(".")-1)) >= 4) {
 flashver=4
}

if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0
   && (navigator.userAgent.indexOf("Windows")>=0 && navigator.userAgent.indexOf("3.1")<0)) {
document.write('\<SCRIPT LANGUAGE=VBScript\> \n');
        document.write('on error resume next ');
        document.write('\n');
document.write('If IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3")) Then ');
document.write('\n');
document.write('flashver = 3 ');
document.write('\n');
document.write('End If ');
document.write('\n');
document.write('If IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4")) Then ');
document.write('\n');
document.write('flashver = 4 ');
document.write('\n');
document.write('End If ');
document.write('\n');
        document.write('\<\/SCRIPT\> ');
        document.write('\n');
}

if (flashver > 2)
{document.write('&lt Flash Version ');
document.write(flashver);
document.write(' detected &gt')};

if (flashver > 3)
{location.href="http://www.flash4version.com"}
else
{location.href="http://www.textversion.com"};

</SCRIPT>
0
 
coopaCommented:
PS.  This script should sit in the body of your html file, not in the head like most scripts.


<html>
<head>
<title>test</title>
</head>
<body>

Your page here

<script>  My script here  </script>

</body>
</html>
0
 
YogeyAuthor Commented:
I've accepted this answer because it seems to be working best.
The other scripts only work partially - just in Explorer and not in Netscape or just on PC's and not on a Mac(!)

Thanx to all of you.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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