Internet Explorers Expression Property | February 15, 2004
Ever heard of Internet Explorers expression property? Me neither. That was until I read this article.
Comment
I just came across that article also when I was looking to see how to control max-width in IE. I’ve used it to do just that in my blog and it seems to work very well. Another addition to the toolbox…
Comment
You might wanna check out:
http://doxdesk.com/software/js/minmax.html
I personally think that’s a better solution.
Comment
Yep, IE proprietary. However, it really isn’t that bad of an idea. Perhaps MS should have presented this property to the W3C instead of arrogantly adding it on their own. Then again, one could say that about a thousand other MS actions, so no big surprise.
Comment
I think this came up earlier, and ended up being mentioned in the same site as the noodle incident with all the box designs… http://www.thenoodleincident.com/tutorials/box_lesson/validation.html
Anyway, the main argument he presented against it, and one that I am inclined to agree with is that for better or for worse, it doesn’t validate. The last thing we need is to realize 20 years from now when we all use CSS15 that the expression property has been integrated into the spec, but in a completely different way.
So, we have all these old sites that use code in non-valid ways that we don’t remember how to fix because we FORGOT what the reasoning behind it was.
Arguments for such things can be made both ways, I personally hated the min-max javascript solution (lags), and find the expression method cleaner were it not for the fact that it can’t validate.
Comment
Huh. It didn’t change my url to a link. Lets try it again, ..about validating
Comment
Actually, I have. I use to use it a lot, then switched to Mozilla and learned it was proprietry. Plus, I’m now a lot more familiar with the box model so as to not require DOM calculations.
Comment
Interesting. I hadn’t heard of it. I use some of these MS propriatary CSS extensions on projects that must work perfectly in IE, but I always feel sick about it. On my personal site, I stick to stands only. But, in the real world, things often have to work perfectly in IE, and this is very handy to know!
Comment
A co-worker pointed this out to me and I thought it would be great until I tried it. When I tried it on a page with an XHTML 1.0 transitional doctype IE 6 crashed every time I resized to the width I was testing for. Remove the doctype and it worked again. I tried e-mailing the author and never heard back.
Comment
Yeah, I’ve found the minmax script to be easier to manage. The lags don’t bother me so much because, I figure, most of the time they’ll be arriving with their window at a set size, and it’ll stay that way.
Comment
Do anybody have a copy of the doxdesk minmax.js script? It is not on doxdesk anymore…
Comment
Seemed to be an answer to my prayers on getting IE to understand a design which needed a min-height value except one thing. It causes IE to crash.
Using XHTML 1.0 transitional the browsers either freezes up or doesn’t pull up the page at all! Strange as it’s a proprietary IE extension.
Nice fix for HTML but avoid if using XHTML.
Comment
A little more info on the crashing of IE.
In my particular case I was trying to create a centered layout thats width was 80% of the screen but with a min-width of 400px. The containing div I was applying the rule to had a 1px border on all sides. I found that when I removed the border from either the right or the left side it worked, if I had a border on both sides IE crashed.
Weird.
Comment
That’s great. I first found out about the usability aspects of max-width columns from the maxdesign site, and now use the feature on nearly all my sites.
Comment
I’ve predicted for years that CSS would become scriptable sooner or later. Too bad this implementation is proprietary for IE.
Comment
expression() can be used for lots of things. For example, I’ve managed to cajole it injecting markup to emulate the content: property in various circumstances (http://www.jasonkarldavis.com/articles/gir/). I know Brothercake has adapted my “one-time use” expression() for certain hacks in his accessible dropdown menu (http://www.udm4.com).
And so on. Just be careful not to overdo it. And remember that unless you are using a one-time use expression(), it will constantly reevaluatae and hit the performance severely.
My one-time use hack gets around this by replacing:
css-property: expression(js expr);
with:
css-property: expression(“somedefaultvalue”, this.runtimeStyle.cssProperty = js expr);
So it only evaluates once, then is replaced with a non-expression value. :)
Comment
I use the expression property a lot to implement IE only hacks. It works great. I’m sure that there is a better way to implement IE only hacks, I just don’t know it. I use both XHTML transitional and strict and haven’t had problems with it once I learned you have to add a litting padding to the numbers you are dealing with. For instance:
width : 100%;
min-width: 500px;
width: expression(document.body.clientWidth < 504? “500px”: “100%” )
I also found problems using “auto” as a parameter. I still use this a lot at work as IE is used by around 93% of our public users and 99.9% of our intranet users.
Comment
For the benefit of all, I’ve posted my own enhancements to Svend’s expression here:
http://tom-lee.blogspot.com/2006/03/how-many-pixels-in-em-part-2.html
Comments on: Internet Explorers Expression Property
Jump to the comment form