Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
Andrew  
#1 Posted : Monday, December 08, 2003 7:39:00 PM(UTC)
Andrew

Rank: Advanced Member

Groups: Member, Administration
Joined: 8/2/2003(UTC)
Posts: 863

Thanks: 2 times
Was thanked: 25 time(s) in 25 post(s)
Hello everyone,

Sometimes you may wish to check whether Image Uploader is already installed in the browser (for example to be able to omit installation instructions for users who already have it installed). The script below demonstrates how to do it. The idea is extremely simple - try to create instanse of the Image Uploader. If you failed, it means that no Image Uploader is installed, otherwise Image Uploader is available.

Code:
<HTML>
<BODY>
<SCRIPT language="JavaScript">
try
{
	var oImageUploader = new ActiveXObject("Aurigma.ImageUploader.1");
}
catch(e)
{
}
if (oImageUploader == null)
{
	alert("No Image Uploader installed!");
}
else
{
	alert("Image Uploader is installed");
}
</SCRIPT>
</BODY>
</HTML>

Edited by user Thursday, December 20, 2007 7:07:55 PM(UTC)  | Reason: Not specified

Andrew  
#2 Posted : Saturday, February 14, 2004 1:44:00 PM(UTC)
Andrew

Rank: Advanced Member

Groups: Member, Administration
Joined: 8/2/2003(UTC)
Posts: 863

Thanks: 2 times
Was thanked: 25 time(s) in 25 post(s)
I have made some more discovering.

The try {} catch{} statement is supported in Internet Explorer 5.0 and higher only. To get this code working on earlier versions of IE, it is is better to use VBScript with On Error Resume Next statement for handling errors in old browsers.

However as in some browsers VBScript may be unsupported (for example Internet Explorer for Mac will show a error if it meet VBScript), we check the browser version and write VBScript function dynamically.

Code:
<script language="JavaScript">
<!--
//Image Uploader detection
if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1)) {
    document.writeln('<script language="VBscript">');
    document.writeln('Function supportImageUploader()');        
    document.writeln('  If ScriptEngineMajorVersion >= 2 Then');    
    document.writeln('	  On Error Resume Next');
    document.writeln('	  supportImageUploader = "NotInstalled"');    
    document.writeln('    If IsObject(CreateObject("Aurigma.ImageUploader")) Then');
    document.writeln('      supportImageUploader = "Installed"');
    document.writeln('    End If');        
    document.writeln('	Else');
    document.writeln('    supportImageUploader = "Unsupported"');
    document.writeln('	End If');
    document.writeln('End Function');
    document.writeln('</scr' + 'ipt>');
}
else {
    document.writeln('<script language="JavaScript">');
    document.writeln('function supportImageUploader() {');
    document.writeln('	return "Unsupported";');
    document.writeln('}');
    document.writeln('</scr' + 'ipt>');
}

//Show either Image Uploader or alternative text
switch (supportImageUploader()){
	case "NotInstalled":
		alert("NotInstalled");
	break;
	case "Installed":
		alert("Installed");
	break;
	default: 
		alert("Unsupported");
}
//-->
</script>

Edited by user Thursday, December 20, 2007 6:38:22 PM(UTC)  | Reason: Not specified

Fedor  
#3 Posted : Tuesday, March 30, 2004 9:06:00 PM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 7/28/2003(UTC)
Posts: 1,481

Thanks: 3 times
Was thanked: 40 time(s) in 39 post(s)
Best regards,
Fedor Skvortsov
Fedor  
#4 Posted : Sunday, May 02, 2004 9:45:00 PM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 7/28/2003(UTC)
Posts: 1,481

Thanks: 3 times
Was thanked: 40 time(s) in 39 post(s)
Note as Image Uploader 1.x and 2.x have different progid, we should use for version 1.x following code:

IsObject(CreateObject("Aurigma.ImageUploader"))

and for version 2.x:

IsObject(CreateObject("Aurigma.ImageUploader2"))
Best regards,
Fedor Skvortsov
Fedor  
#5 Posted : Wednesday, February 13, 2008 3:28:00 PM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 7/28/2003(UTC)
Posts: 1,481

Thanks: 3 times
Was thanked: 40 time(s) in 39 post(s)
========================================================
02/14/2008, Fedor
This topic is out of date.

You can check whether ActiveX control is installed using getActiveXInstalled method of appropriate XXXWriter object.
========================================================

Edited by user Tuesday, October 28, 2008 6:15:45 AM(UTC)  | Reason: Not specified

Best regards,
Fedor Skvortsov
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.