Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / JavaScript / December 2007



Tip: Looking for answers? Try searching our database.

History exercise: Mac IE and XMLHttpRequest

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Patrick Nolan - 29 Dec 2007 01:52 GMT
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?
David Mark - 29 Dec 2007 02:11 GMT
> I'm working on cross-platform portability of some javascript.
> My Macintosh testing platform is rather old.  It has Safari
[quoted text clipped - 15 lines]
> 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.
Patrick Nolan - 30 Dec 2007 00:58 GMT
>> I'm working on cross-platform portability of some javascript.
>> My Macintosh testing platform is rather old.  It has Safari
[quoted text clipped - 25 lines]
>
> (and post the result.)

It says "undefined".  This looks hopeless.  

> I would be interested to know just what window.ActiveXObject is in Mac
> IE.  It can't possibly be a useful constructor.
David Mark - 30 Dec 2007 01:28 GMT
> >> I'm working on cross-platform portability of some javascript.
> >> My Macintosh testing platform is rather old.  It has Safari
[quoted text clipped - 27 lines]
>
> 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.
Patrick Nolan - 30 Dec 2007 04:47 GMT
> Not really.  Looking at your feature test:
>
[quoted text clipped - 20 lines]
>    }
>  }

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.

> You shouldn't get any alerts or errors.  If you do get an error, it
> should be apparent which line caused it.
David Mark - 30 Dec 2007 04:59 GMT
> > Not really.  Looking at your feature test:
>
[quoted text clipped - 23 lines]
> 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.
Thomas 'PointedEars' Lahn - 30 Dec 2007 09:38 GMT
> 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 <news:4775B3A0.7080607@PointedEars.de> fully?  (Unlike you, I
quote properly, so where there is a quote block there is a response below it.)

PointedEars
Signature

   realism:    HTML 4.01 Strict
   evangelism: XHTML 1.0 Strict
   madness:    XHTML 1.1 as application/xhtml+xml
                                                   -- Bjoern Hoehrmann

Thomas 'PointedEars' Lahn - 29 Dec 2007 02:40 GMT
> I'm working on cross-platform portability of some javascript.
> My Macintosh testing platform is rather old.  It has Safari
[quoted text clipped - 5 lines]
>   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".
[quoted text clipped - 5 lines]
> 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
Signature

var bugRiddenCrashPronePieceOfJunk = (
   navigator.userAgent.indexOf('MSIE 5') != -1
   && navigator.userAgent.indexOf('Mac') != -1
)  // Plone, register_function.js:16

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.