js flash-check

Chris Kurt

Erfahrenes Mitglied
hallo da draußen,

habe schon ein, zwei codes ausprobiert aber finde nicht ganz das richtige:

eine flash-detection in javascript. muß einfach nur der check sein ob flash ja oder nein, keine versionsabfrage. allerdings sollte es für netscape und ie funzen....

he, wenn jemand bescheid weiß, würde mich sehr freuen über ein paar wenige zeilchen code...

thanx a lot...
 
habßs schon selber gefunden.

für alles die´s wissen wollen:

//DIRECTS THE USER TO A FLASH PAGE IF THEY HAVE THE PLUGIN, A NON FLASH IF THEY DON'T.
//ALSO REDIRECTS MAC/IE USERS TO A SEPERATE PAGE.

//PARAMETERS:
//MACIE - THE HTML PAGE YOU WANT MAC/IE USERS TO BE FORWARDED TO.
//FLASH - THE HTML PAGE CONTAINING THE FLASH MOVIE.
//NOFLASH - THE HTML PAGE YOU WANT USERS WITHOUT THE PLUGIN FORWARDED TO.
function detectFlash(macie, flash, noflash)
{
//IF THE USER IS RUNNING IE ON A MAC, FORWARD THEM TO THE MAC/IE PAGE
//SINCE EXTERNAL SCRIPTING WON'T WORK ON THIS PLATFORM, YOU MIGHT WANT TO TELL THEM TO USE NETSCAPE
if (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.indexOf("Mac") != -1 )
{
window.location=macie;
}
var plugin = (navigator.mimeTypes &&
navigator.mimeTypes["application/x-shockwave-flash"] ?
navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0);

if ((navigator.appName == "Microsoft Internet Explorer" &&
navigator.appVersion.indexOf("Mac") == -1 &&
navigator.appVersion.indexOf("3.1") == -1) || (plugin &&
parseInt(plugin.description.substring(plugin.description.indexOf(".")-1))>=
4))
{
//IF THE USER HAS THE CORRECT PLUGIN, FORWARD THEM TO THE FLASH PAGE
window.location=flash;
}
else
{
//IF THE PLUGIN CANNOT BE FOUND, FORWARD THE USER TO THE NON FLASH PAGE
window.location=noflash;
}
}

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

Put that in in between the <head>...</head> tags in your HTML page, then call it, specifying the three different pages as parameters. Like this:

<body onLoad="javascript:detectFlash('macie.html', 'flash.html', 'noflash.html')">



;-]



·kuat·
 
Zurück