Closed bendavies closed 13 years ago
Interesting...
Are you able to recreate this issue in the form of an example I can run in IE8, or detail the steps you went through that resulted in this error?
Testing window.ActiveXObject before XMLHttpRequest doesn't sit well with me as the standards based XHR object is the best of the two options and your suggested method would always defer to ActiveX.
Also, if ActiveX was disabled on your machine then it would fall back to XHR which would still throw an error in your case - although the try/catch would handle that and return null, preventing selectivizr from starting.
No feedback and unable to recreate - closing
Keith,
Apologies, just got notification that you replied to this. Strangely I can't replicated this any more either. I thought for a second that it might be IE8's Compatibility mode, but it seems not.
Cheers, Ben
I am encountering this exact issue on first load of a page. If I refresh, the error goes away.
OS: [On a VM image]: Windows XP Pro SP3 Browser: IE8, DocMode: IE8 Standards
I made a copy of my page and reduced the code to a minimum that repro's the issue:
SEL-TEST-IZR.HTML
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/mootools/1.3.1/mootools.js"></script>
<script type="text/javascript" src="scripts/selectivizr.js"></script>
<meta charset='UTF-8' />
</head>
<body>
</body>
</html>
The charset meta-tag seems vital to reproducing the issue. Just out of curiosity, I tried toggling IE's page encoding between Western European (default), Auto-Select, and UTF-8, none of which changed the outcome.
Also, the choice of JavaScript libraries does not seem to change the outcome; I personally am using jQuery 1.8.1 and Mootools 1.3.2 (only for nth-child and first-/last-of-type).
TEST SETUP
TEST STEPS
ACTUAL RESULT Page loads with errors. Double-clicking the error icon in the status bar brings up IE's error window: Object doesn't support this property or method selectivizr.js Line: 378 Code: 0 Char: 4 URI: http://[...]/scripts/selectivizr.js
EXPECTED RESULT Page loads without errors.
I'm encountering this issue as well on the current version of selectivizr. IE8 reports an invalid argument to the open function being called on the XHR.
We encountered an identical issue today using 1.0.3.b. Attempting to create a new XHR object returns an exception in IE8 (line 384) on initial load or hard refresh.
Our working solution:
if (win.XMLHttpRequest) {
try {
return new win.XMLHttpRequest;
} catch (e) {}
}
try {
return new ActiveXObject('Microsoft.XMLHTTP');
} catch (e) {
return null;
}
win.XMLHttpRequest throws: Message: Object doesn't support this property or method
Consider testing for ActiveXObject first and falling back to XMLHttpRequest after: