www.webdeveloper.com
Results 1 to 2 of 2

Thread: Why should I use VBScript to create activeX object?

  1. #1
    Join Date
    Dec 2004
    Posts
    25

    Why should I use VBScript to create activeX object?

    Hi,

    I am wanting to detect if the users browser has the Shockwave plug-in installed. At the moment I am focussing on detecting it within IE.

    I have found two methods and I am not sure which one is the best.

    One method simply detects if the browser supports ActiveX in which case I create a new ActiveX object:
    Code:
    var shockwaveInstalled = new ActiveXObject('SWCtl.SWCtl');
    Then check if it returns TRUE
    Code:
    if(shockwaveInstalled) installed = true;
    else installed = false;
    Meanwhile there is a script that Adobe suggests I use which I found here:
    http://kb2.adobe.com/cps/157/tn_15722.html

    What differs in this script is it use JavaScript to write out VBScript that essentially calls the same ActiveX Object e.g.
    Code:
    } else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.userAgent.indexOf("Windows 95")>=0 || navigator.userAgent.indexOf("Windows 98")>=0 || navigator.userAgent.indexOf("Windows NT")>=0 )) {
    	document.write('<SCRIPT LANGUAGE=VBScript\> \n');
    	document.write('on error resume next \n');
    	document.write('set tSWControl = CreateObject("SWCtl.SWCtl") \n');
    	document.write('if IsObject(tSWControl) then \n');
    	document.write('tVersionString = tSWControl.ShockwaveVersion("") \n');
    	document.write('end if');
    	document.write('</SCRIPT\> \n');
    }
    It seems to be that VBScript had to be used at one point as JavaScript could not create ActiveX objects. Does anyone know if this is true as my feeling is I should avoid the VBScript method but I am not sure if it has a better compatibility with older versions of IE installed on versions of Windows before XP.

    Any thoughts?

    Thanks

  2. #2
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,279
    There may be a legacy reason for using VBScript instead of JScript (and JavaScript running under MSIE is actually JScript) but there was never any reason to use JScript to write the VBScript. And that second has several problems with it.

    You will find, however, that there are a few things that you can do with VB that you can't do with JS. But something in your JS block can call something in your VB.
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles