History exercise: Mac IE and XMLHttpRequest

P

Patrick Nolan

I'm working on cross-platform portability of some javascript.
My Macintosh testing platform is rather old. It has Safari
1.3.2 and Internet Explorer 5.2. I got Safari working, but
now IE is causing trouble. It chokes on this:

if (window.XMLHttpRequest)
nameReq = new XMLHttpRequest();
else if (window.ActiveXObject)
nameReq = new ActiveXObject("Microsoft.XMLHTTP");

The error message on the last line is "Object doesn't support
this action".

I can't pretend to understand much of this. I'm copying
patterns that I find in various places.

Is it possible that this browser is just too old to support
XMLHttpRequest? If so, does anyone know the earliest version
for which this would work?
 
D

David Mark

I'm working on cross-platform portability of some javascript.
My Macintosh testing platform is rather old.  It has Safari
1.3.2 and Internet Explorer 5.2.  I got Safari working, but
now IE is causing trouble.  It chokes on this:

  if (window.XMLHttpRequest)
      nameReq = new XMLHttpRequest();
  else if (window.ActiveXObject)
      nameReq = new ActiveXObject("Microsoft.XMLHTTP");

The error message on the last line is "Object doesn't support
this action".

I can't pretend to understand much of this.  I'm copying
patterns that I find in various places.

Is it possible that this browser is just too old to support
XMLHttpRequest?  If so, does anyone know the earliest version
for which this would work?

It is too old to have XMLHttpRequest and certainly won't create and
ActiveX object. However, should safely exclude it from using Ajax,
rather than throw an error. Try this:

else if (typeof window.ActiveXObject == 'function' || (typeof
window.ActiveXObject == 'object' && window.ActiveXObject))

If that fails, do this:

alert(typeof window.ActiveXObject);

(and post the result.)

I would be interested to know just what window.ActiveXObject is in Mac
IE. It can't possibly be a useful constructor.
 
T

Thomas 'PointedEars' Lahn

Patrick said:
I'm working on cross-platform portability of some javascript.
My Macintosh testing platform is rather old. It has Safari
1.3.2 and Internet Explorer 5.2. I got Safari working, but
now IE is causing trouble. It chokes on this:

if (window.XMLHttpRequest)
nameReq = new XMLHttpRequest();
else if (window.ActiveXObject)
nameReq = new ActiveXObject("Microsoft.XMLHTTP");

It would appear that this branch order should be reversed for general use as
Microsoft's XMLHttpRequest pseudo-native object as of Internet Explorer 7
does not allow requests on the local file system while that works with the
genuine ActiveX/COM object.
The error message on the last line is "Object doesn't support
this action".

I can't pretend to understand much of this. I'm copying
patterns that I find in various places.

Is it possible that this browser is just too old to support
XMLHttpRequest? If so, does anyone know the earliest version
for which this would work?

We have discussed recently that the ActiveX identifier "Microsoft.XMLHTTP"
means at most MSXML 3.0, which first shipped with Internet Explorer 6.0 for
Windows. However, previous versions of MSXML appear to have shipped only
with the Windows versions of Internet Explorer:

http://en.wikipedia.org/wiki/MSXML
http://support.microsoft.com/kb/269238

You can probably use conditional compilation and try..catch to work around
the error message.

That said, IE 5.2 (as well as Safari 1.3.x) for Mac is hopelessly outdated
and should no longer be actively developed for; in our company, at least, we
have done it only upon a single customer's request.

http://en.wikipedia.org/wiki/Internet_Explorer#Version_5
http://www.microsoft.com/mac/products/internetexplorer/internetexplorer.aspx?pid=internetexplorer


PointedEars
 
P

Patrick Nolan

It is too old to have XMLHttpRequest and certainly won't create and
ActiveX object. However, should safely exclude it from using Ajax,
rather than throw an error. Try this:

else if (typeof window.ActiveXObject == 'function' || (typeof
window.ActiveXObject == 'object' && window.ActiveXObject))

If that fails, do this:

alert(typeof window.ActiveXObject);

(and post the result.)

It says "undefined". This looks hopeless.
 
D

David Mark

It says "undefined".  This looks hopeless.  

Not really. Looking at your feature test:


if (window.XMLHttpRequest)
nameReq = new XMLHttpRequest();
else if (window.ActiveXObject)
nameReq = new ActiveXObject("Microsoft.XMLHTTP");

The last line should not execute if window.ActiveXObject is
undefined. Are you sure that is the line that errors?

I seem to remember having some weird problems like this with a very
old Mac AOL browser that was based on IE. Try this cleaned up version
as a test case:

if (typeof window.XMLHttpRequest != 'undefined') {
alert('Creating XMLHttpRequest');
nameReq = new window.XMLHttpRequest();
}
else {
if (typeof window.ActiveXObject != 'undefined') {
alert('Creating ActiveX');
nameReq = new window.ActiveXObject("Microsoft.XMLHTTP");
}
}

You shouldn't get any alerts or errors. If you do get an error, it
should be apparent which line caused it.
 
P

Patrick Nolan

Not really. Looking at your feature test:


if (window.XMLHttpRequest)
nameReq = new XMLHttpRequest();
else if (window.ActiveXObject)
nameReq = new ActiveXObject("Microsoft.XMLHTTP");

The last line should not execute if window.ActiveXObject is
undefined. Are you sure that is the line that errors?

I seem to remember having some weird problems like this with a very
old Mac AOL browser that was based on IE. Try this cleaned up version
as a test case:

if (typeof window.XMLHttpRequest != 'undefined') {
alert('Creating XMLHttpRequest');
nameReq = new window.XMLHttpRequest();
}
else {
if (typeof window.ActiveXObject != 'undefined') {
alert('Creating ActiveX');
nameReq = new window.ActiveXObject("Microsoft.XMLHTTP");
}
}

I get the alert "Creating ActiveX". Then it gets an error on the
next line: nameReq = new window.ActiveXObject("Microsoft.XMLHTTP");
The error is "Object doesn't support this action".
This is the same place the error occurred before. (I'm depending on
the IE error popup and its source code display to show the correct
line number. So far I have no reason to doubt it.)

I'm beginning to believe that the ActiveXObject doesn't support the
Microsoft.XMLHTTP action in this antique browser. Maybe I should
not try to support this version. It's fairly unlikely that many
people will use it.
 
D

David Mark

I get the alert "Creating ActiveX".  Then it gets an error on the
next line: nameReq = new window.ActiveXObject("Microsoft.XMLHTTP");

That doesn't make any sense. What does these show:

alert(typeof window.ActiveXObject == 'undefined');

alert(typeof window.ActiveXObject != 'undefined');
The error is "Object doesn't support this action".

It should never get there if window.ActiveXObject is undefined.
This is the same place the error occurred before.  (I'm depending on
the IE error popup and its source code display to show the correct
line number.  So far I have no reason to doubt it.)

I'm beginning to believe that the ActiveXObject doesn't support the
Microsoft.XMLHTTP action in this antique browser.  Maybe I should

ActiveX doesn't do anything on a Mac. That is why
window.ActiveXObject is undefined. It should be trivial to detect
that and skip the of creation the object.
not try to support this version.  It's fairly unlikely that many
people will use it.

Yes, it is basically a waste of time.
 
T

Thomas 'PointedEars' Lahn

Patrick said:
I'm beginning to believe that the ActiveXObject doesn't support the
Microsoft.XMLHTTP action in this antique browser [IE 5.2 for Mac]. [...]

Have you read <fully? (Unlike you, I
quote properly, so where there is a quote block there is a response below it.)


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top