“Object doesn’t support this action” error in IE7/IE8

Yet another IE woe – if you want your code to work on IE – be forewarned that harmless looking like the one below would break with “Object doesn’t support this action” error.

items=[];//define a array
length=items.length;//throws error since the term length is treated special in IE
for(item in items){
//again the term item is treated in a special way in IE – would throw the same error.
}

Either make sure these are local variables by prefixing them with var.

items=[];//define a array
var length=items.length;//throws error since the term length is treated special in IE
for(var item in items){
//again the term item is treated in a special – would throw the same error.
}
otherwise rename the variables
items=[];//define a array
mylength=items.length;//throws error since the term length is treated special in IE
for(myitem in items){
//again the term item is treated in a special – would throw the same error.
}

After a lot of digging, I found that any variable declared without the var keyword is considered to global in Javascript. Specifically in IE – They get attached to a global collection called document.all.

So helper methods associated with document.all such as

  1. item
  2. namedItem
  3. tags
  4. urns

and the property “length” are all considered reserved with respect to global variables in IE.

Also refrain from using these words as IDs for any HTML element.

Microsoft NONCLIENTMETRICS doesnt work in XP :(

They have done it again!
In the RTM of the Vista SDK they have added a new member to the NONCLIENTMETRICS struct.
#if(WINVER >= 0x0600)
int     iPaddedBorderWidth;
#endif /* WINVER >= 0x0600 */
So if you set WINVER to 0x0600 and compile your application it will no longer work on XP.
If you look at the documentation in MSDN it doesn’t mention anything about the struct size change for Vista so how are developers supposed to know this will break backward compatibility?

Definitely ugly, and will hit a lot of people who forgot or didn’t set WINVER in their app, but it’s not unprecedented.  Example would be MENUITEMINFO with the hbmpItem structure (however in that case they got it wrong, it works fine on Windows 98 SE not just WINVER >=0x0500 as it is in the SDK headers).
If a user defines _WIN32_WINNT but not WINVER, then WINVER is defined as the value of _WIN32_WINNT.  However, if a user defines both _WIN32_WINNT and WINVER, then they are separate.    But if neither are set, then WINVER is defaulted to 0x0600, a bad thing in this case.
So try using _WIN32_WINNT = 0x0600 and WINVER = 0x0501.    Not sure how many definitions would be missing with this combination.  If too many are missing then set cbSize at runtime based on the current OS (e.g. (BYTE)GetVersion() < 6 )

http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=930256&SiteID=1