Test for existence of the Cortona 3D plugin

If you want to check whether your visitor has the Cortona 3D viewer plugin installed in the browser, you can use the following javascript:

<script type="text/javascript">
    var cortonaPossible = isWin;// is the plugin available for this platform
    var cortonaInstalled = false;// is the plugin actually installed
    var cortonaChecked = false;// if 'cortonaPossible': did we do a check to find out if we have the plugin installed. This in case of new browsers which are not supported by this check
    var isIE  = !!(navigator.appVersion.indexOf("MSIE") != -1);
    var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
    if (cortonaPossible)
        cortonaChecked = true;
        if (navigator.plugins && navigator.plugins.length)
            for (var i = 0; i < navigator.plugins.length; i++)
                if (navigator.plugins[i].name.toLowerCase().indexOf('cortona3d') > -1)
                    cortonaInstalled = true;
        // detect VRML and X3D plugins in Microsoft Internet Explorer, only with Windows
        // copied from http://cic.nist.gov/vrml/vbdetect.html
        } else if (navigator.appName == "Microsoft Internet Explorer" && isWin)
            // IEDetectObject is used to detect ActiveX Controls
            document.writeln('<SCRIPT LANGUAGE="VBScript">');
            document.writeln('function IEDetectObject(activeXControlName)');
            document.writeln('    On Error Resume Next');
            document.writeln('    IEDetectObject = IsObject(CreateObject(activeXControlName))');
            document.writeln('End function');
            document.writeln('</SCR' + 'IPT>');
            if (IEDetectObject('Cortona.Control.1'))
                cortonaInstalled = true;
        } else
            cortonaChecked = false;

After having included the script above in your web page, you can use the following script in the body of your website to yes/no display the Cortona 3D plugin:

<script type="text/javascript">
    if (cortonaInstalled) {
        document.write('<iframe src="cortona3d-page.html" width="100%" height="300" frameborder="0"></iframe>');
    } else if (cortonaPossible) {
        document.write('<div class="alert alert-warning">In order to show you 3D content, you will need to <a href="http://www.cortona3d.com/cortona3d-viewers" target="_blank">install the Cortona3D plugin</a>. Please click the <a href="http://www.cortona3d.com/cortona3d-viewers" target="_blank">Install link</a> to start installation.<br>After installation, please <a href="javascript:self.location.reload()">reload this page</a>.</div>');
    } else {
        document.write('<div class="alert alert-error">We probably cannot show you the 3D contents on this page, due to plugin incompatibilities. Maybe there <i>is<'+'/i> a compatible plugin; therefor please try to <a href="http://www.cortona3d.com/cortona3d-viewers" target="_blank">install the Cortona3D plugin</a>.<br>If installation succeeded, please <a href="javascript:self.location.reload()">reload this page</a>.</div>');

Thanks to the source code of http://cic.nist.gov/vrml/vbdetect.html!

del.icio.us Digg StumbleUpon Facebook Technorati Fav reddit Google Bookmarks
| Viewed 16466 times

No comments yet.

(will not be published)
Leave this field empty