home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2003 June (Bonus) / Services_2003.bin / services_2003 / library / script / flashSwitch.js < prev    next >
Encoding:
JavaScript  |  2002-07-25  |  3.3 KB  |  95 lines

  1.  
  2. //Check for MSIE and Windows-OS
  3.  
  4. function msie_windows_detect(){
  5.     var mymsie_windows = 0;
  6.     if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1)){
  7.     var mymsie_windows = 1;
  8.     }
  9.     return mymsie_windows;
  10. }
  11.  
  12. function flashdetect(){
  13.     for(i=0; i<10; ++i){
  14.     var myflashplugin = WM_pluginDetect('Flash '+i, 'swf', 'application/x-shockwave-flash','ShockwaveFlash.ShockwaveFlash.'+i);
  15.         if (myflashplugin==true){
  16.             var myflashpluginversion = i;
  17.             break
  18.         }
  19.     }
  20.     return myflashplugin;
  21. }    
  22.  
  23.  
  24. function plugindetectVB(){
  25.     var WM_startTagFix = '</';
  26.       document.writeln('<script language="VBscript">');
  27.       document.writeln('\'This will scan for plugins for all versions of Internet Explorer that have a VBscript engine version 2 or greater.');
  28.       document.writeln('\'This includes all versions of IE4 and beyond and some versions of IE 3.');
  29.       document.writeln('Dim WM_detect_through_vb');
  30.       document.writeln('WM_detect_through_vb = 0');
  31.       document.writeln('If ScriptEngineMajorVersion >= 2 then');
  32.       document.writeln('  WM_detect_through_vb = 1');
  33.       document.writeln('End If');
  34.       document.writeln('Function WM_activeXDetect(activeXname)');
  35.       document.writeln('  on error resume next');
  36.       document.writeln('  If ScriptEngineMajorVersion >= 2 then');
  37.       document.writeln('     WM_activeXDetect = False');
  38.       document.writeln('     WM_activeXDetect = IsObject(CreateObject(activeXname))');
  39.       document.writeln('     If (err) then');
  40.       document.writeln('        WM_activeXDetect = False');
  41.       document.writeln('     End If');
  42.       document.writeln('   Else');
  43.       document.writeln('     WM_activeXDetect = False');
  44.       document.writeln('   End If');
  45.       document.writeln('End Function');
  46.       document.writeln(WM_startTagFix+'script>');
  47.     return WM_detect_through_vb;
  48. }
  49.  
  50.     
  51. function WM_pluginDetect(plugindescription, pluginxtension, pluginmime, activeXname){
  52. var i,plugin_undetectable=0,detected=0, daPlugin=new Object();
  53.  
  54.         if (msie_windows && myWM_detect_through_vb){
  55.           plugin_undetectable = 0;
  56.       } else {
  57.           plugin_undetectable = 1;
  58.          }
  59.     
  60.       if(navigator.plugins) {
  61.           numPlugins = navigator.plugins.length;
  62.           if (numPlugins > 1) {
  63.           if (navigator.mimeTypes && navigator.mimeTypes[pluginmime] && navigator.mimeTypes[pluginmime].enabledPlugin && (navigator.mimeTypes[pluginmime].suffixes.indexOf(pluginxtension) != -1)) { 
  64.               if ((navigator.appName == 'Netscape') && (navigator.appVersion.indexOf('4.0') != -1)) { 
  65.               for(i in navigator.plugins) {
  66.                   if ((navigator.plugins[i].description.indexOf(plugindescription) != -1) || (i.indexOf(plugindescription) != -1)) { 
  67.                   detected=1;
  68.                   break;
  69.                   }
  70.               }
  71.               } else {
  72.               for (i = 0; i < numPlugins; i++) {
  73.                   daPlugin = navigator.plugins[i];
  74.                   if ((daPlugin.description.indexOf(plugindescription) != -1) || (daPlugin.name.indexOf(plugindescription) != -1)) {
  75.                   detected=1;
  76.                   break;
  77.                   }
  78.               }
  79.               }
  80.     
  81.           if (navigator.mimeTypes[pluginmime] == null) {
  82.               detected = 0;
  83.               }
  84.           }
  85.           return detected;
  86.           } else if((msie_windows == 1) && !plugin_undetectable){
  87.           return WM_activeXDetect(activeXname);
  88.           } else {         
  89.           return 0;
  90.           }
  91.       } else {
  92.          return 0;
  93.       }
  94. }
  95.