Findings: Porting to IE7
January 10th, 2007
In testing and porting several sites to IE7 over the past several days, I’ve been rather pleased at the CSS development. This means that fixes went along the line of standards, not hacks.
Just replacing hacks.
CSS Hacks has a nice comprehensive list. My previous old favorite was The Underscore hack. It left nice readable code, without seeing stars (quite frequent, where I work). It’s replacement is the !important hack.
Some example code:
p { color: red; _color: blue; }
p { color: red; }
* html p { color: blue; }
And my newly preferred method:
p { color: red !important; color: blue; }
In IE6, text is blue; in others, red. Simple enough.
The biggest issue I ran into was when widths were set by this method - The box model bug (which, unfortunately for all, the w3c got wrong in the specification). The second was the doubled margin bug, which is an actual bug (and can be fixed with display: inline;). After that, properly clearing floats was the biggest issue.
And one AJAX-related issue:
if(reqVar==null) {
if (window.XMLHttpRequest) {
reqVar = new XMLHttpRequest();
reqVar.overrideMimeType("text/xml");
}
else if (window.ActiveXObject) {
try {
reqVar = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e) {
try {
reqVar = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e) {
}
}
}
}
The thing is, IE7 supports native XMLHttpRequests - but not overrideMimeType. The fix? Test for window.ActiveXObject first.
-Sud.
Posted in XHTML |