By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,231 Members | 1,707 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,231 IT Pros & Developers. It's quick & easy.

History exercise: Mac IE and XMLHttpRequest

P: n/a
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?
Dec 29 '07 #1
Share this Question
Share on Google+
6 Replies


P: n/a
On Dec 28, 8:52*pm, Patrick Nolan <p...@glast2.Stanford.EDUwrote:
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.
Dec 29 '07 #2

P: n/a
On 2007-12-29, David Mark <dm***********@gmail.comwrote:
On Dec 28, 8:52*pm, Patrick Nolan <p...@glast2.Stanford.EDUwrote:
>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".

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.)
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.
Dec 30 '07 #3

P: n/a
On Dec 29, 7:58*pm, Patrick Nolan <p...@glast2.Stanford.EDUwrote:
On 2007-12-29, David Mark <dmark.cins...@gmail.comwrote:


On Dec 28, 8:52*pm, Patrick Nolan <p...@glast2.Stanford.EDUwrote:
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".
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.)

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.
Dec 30 '07 #4

P: n/a
On 2007-12-30, David Mark <dm***********@gmail.comwrote:
On Dec 29, 7:58*pm, Patrick Nolan <p...@glast2.Stanford.EDUwrote:
>On 2007-12-29, David Mark <dmark.cins...@gmail.comwrote:


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.
>
You shouldn't get any alerts or errors. If you do get an error, it
should be apparent which line caused it.
Dec 30 '07 #5

P: n/a
On Dec 29, 11:47*pm, Patrick Nolan <p...@glast2.Stanford.EDUwrote:
On 2007-12-30, David Mark <dmark.cins...@gmail.comwrote:


On Dec 29, 7:58*pm, Patrick Nolan <p...@glast2.Stanford.EDUwrote:
On 2007-12-29, David Mark <dmark.cins...@gmail.comwrote:
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");
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.
Dec 30 '07 #6

P: n/a
Patrick Nolan wrote:
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:47**************@PointedEars.defully? (Unlike you, I
quote properly, so where there is a quote block there is a response below it.)
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Dec 30 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.