The simple trick for detecting IE8, IE9 and soon IE10 in compatability mode is to look for User Agent strings that contain "MSIE 7.0" and also "Trident/4.0", "Trident/5.0" or "Trident/6.0" respectively. The user agent string for IE7 doesn't contain "Trident" at all. I maintain a SAINT classification...