' alert("Module trackerLib.vbs [v20031027] has loaded."); ' ' ' ' name: trackerLib.vbs ' dir: \htdocs\includes ' by: OpenAsia Solutions Pte Ltd ' func: this library supports the javascript library 'trackerLib.js', which ' provides javascript functions for detecting and communicating usage information, ' including various media player detection routines, coded in Visual Basic; ' the error handling 'on error resume next' provided by vbScript is useful when you ' need to launch ActiveX components to determine if a plugin is supported in IE; ' some applications use 'document.writeln' to let javascript write out the vbScript, ' they do this because vbScript is not compatible with some versions of IE on the Mac; ' note that this approach is not ideal, and is not necessary for IE5 or later, which ' may use the 'try-catch' syntax and try launching the component, as follows: ' detectActiveXControl = new ActiveXObject('MediaPlayer.MediaPlayer.1'); ' and for some components, it is possible to detect them using IE's 'clientCaps' ' (refer to examples in 'trackerLib.js' for more info on how to use 'clientCaps') ' for vbScript language reference, try: ' http://www.netzone.ch/caspdoc/html/vbscript_language_reference.htm ' for more info on detecting plugins, refer to: ' http://www.sonify.org/tutorials/links/pages/other/embedded_audio_part2 ' http://www.agenturcafe.de/STATS/lib/plugins.vb ' http://1ppl.free.fr/html/article074.html ' rev: 20031027, wmc, created this module ' 20031102, wmc, added error handling and fixed bug in 'hasCDROM' that crashed IE ' (replaced 'WMPlayer.OCX.7' with 'WMPlayer.OCX') ' 20031110, wmc, recreated all functions in 'trackerLib.js', making this a ' deprecated library - use only for IE4 browsers ' ' -------------------------------------------------------------------------------- ' Following are the common client-side functions defined in this module. ' -------------------------------------------------------------------------------- ' ' ieHasPlugin checks existence of an installed IE plugin for selected types ' hasCDROM checks for the existence of a CD-ROM drive on the client machine ' ieGetWMPlayerVersion detect Windows Media Player plugin version ' ieGetWMPlayerClassId detect Windows Media Player plugin classid ' ieGetAcrobatVersion detect Acrobat plugin version ' ieGetFlashVersion detect Macromedia Flash plugin version ' showError error handling routine (invoke using 'on error goto' syntax) ' ' declare global variables On Error Resume Next Dim global, trackerLibVb If (Not IsNull(top.dataframe)) Then set global = top.dataframe Else set global = me End If set trackerLibVb = me 'NOTE: "me" is the equivalent of Javascript "this" On Error GoTo 0 Function ieHasPlugin (typeStr) Dim found, supportedTypes found = false supportedTypes = "WM, RM, QT, PDF, SWF" If (isNull(typeStr) OR InStr(supportedTypes + ",", UCase(typeStr + ",")) = -1) Then alert("Javascript error - function 'ieCheckPlayer' called with invalid or missing type.") Else On Error Resume Next found = (found OR (UCase(typeStr) = "WM" AND (NOT IsNull(CreateObject("MediaPlayer.MediaPlayer.1"))))) 'Windows Media found = (found OR (UCase(typeStr) = "RM" AND (NOT IsNull(CreateObject("IERPCtl.IERPCtl"))))) 'RealOne found = (found OR (UCase(typeStr) = "RM" AND (NOT IsNull(CreateObject("rmocx.RealPlayer G2 Control"))))) 'v6 found = (found OR (UCase(typeStr) = "RM" AND (NOT IsNull(CreateObject("RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)"))))) 'v5 found = (found OR (UCase(typeStr) = "RM" AND (NOT IsNull(CreateObject("RealVideo.RealVideo(tm) ActiveX Control (32-bit)"))))) 'v4 found = (found OR (UCase(typeStr) = "QT" AND (NOT IsNull(CreateObject("QuickTimeCheckObject.QuickTimeCheck.1"))))) found = (found OR (UCase(typeStr) = "PDF" AND (NOT IsNull(CreateObject("PDF.PdfCtrl.1"))))) found = (found OR (UCase(typeStr) = "PDF" AND (NOT IsNull(CreateObject("PDF.PdfCtrl.4"))))) found = (found OR (UCase(typeStr) = "PDF" AND (NOT IsNull(CreateObject("PDF.PdfCtrl.5"))))) found = (found OR (UCase(typeStr) = "PDF" AND (NOT IsNull(CreateObject("PDF.PdfCtrl.6"))))) found = (found OR (UCase(typeStr) = "SWF" AND (NOT IsNull(CreateObject("ShockwaveFlash.ShockwaveFlash.1"))))) found = (found OR (UCase(typeStr) = "SWF" AND (NOT IsNull(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))))) found = (found OR (UCase(typeStr) = "SWF" AND (NOT IsNull(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))))) found = (found OR (UCase(typeStr) = "SWF" AND (NOT IsNull(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))))) found = (found OR (UCase(typeStr) = "SWF" AND (NOT IsNull(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))))) found = (found OR (UCase(typeStr) = "SWF" AND (NOT IsNull(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))))) End If ieHasPlugin = found End Function Function hasCDROM () On Error Resume Next Dim wmp, cdroms Set wmp = CreateObject("WMPlayer.OCX") If (NOT IsNull(wmp)) Then Set cdroms = wmp.cdromCollection hasCDROM = cdroms.Count > 0 Else hasCDROM = false End If End Function Function ieGetWMPlayerVersion () On Error Resume Next Dim wmp, version version = "" Set wmp = CreateObject("MediaPlayer.MediaPlayer.1") If IsObject(wmp) Then version = wmp.versionInfo If (version = "") Then Set wmp = CreateObject("WMPlayer.OCX") If IsObject(wmp) Then version = wmp.versionInfo End If End If End If ieGetWMPlayerVersion = version End Function Function ieGetWMPlayerClassId () On Error Resume Next Dim wmp, classid classid = "" Set wmp = CreateObject("MediaPlayer.MediaPlayer.1") If IsObject(wmp) Then classid = wmp.ClientID If IsNull(classid) Then Set wmp = CreateObject("WMPlayer.OCX.7") If IsObject(wmp) Then classid = wmp.ClientID End If End If End If ieGetWMPlayerClassId = classid End Function Function ieGetAcrobatVersion () On Error Resume Next Dim version version = 0 For i = 1 to 8 If Not (IsObject(CreateObject("PDF.PdfCtrl." & i))) Then Else If (i <= 4) Then version = 4 Else version = i End If End If Next ieGetAcrobatVersion = version End Function Function ieGetFlashVersion () On Error Resume Next Dim version version = 0 For i = 2 to 8 If Not (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & i))) Then Else version = i End If Next ieGetFlashVersion = version End Function Function showError (Err) str = "" str = str & "The following Error has occured:" & vbCrLf str = str & "Number: " & Err.Number & vbCrLf str = str & "Description: " & Err.Description & vbCrLf str = str & "Source: " & Err.Source & vbCrLf alert (str) End Function