Weird IE behavior: currentStyle returns null

I am experiencing strange behavior in IE8, which seems to be an IE bug, but I'm not sure. When accessing the currentStyle field from an element, it returns null. If I look at its properties in the viewport, I see that it is defined, and I can view its elements. It seems like if I call the attributes before the distribution, then it will return the correct currentStyle. I was wondering if anyone had seen this behavior before and knows some workarounds. This happens when building a dojo grid. I also cannot override this JavaScript behavior because it is deeply immersed in an external Javascript library (dojo) and I do not have access to the function, primarily for overriding (the function is defined in a different area of ​​the functions).

+5
source share
1 answer

The currentStyle object in IE is asynchronous. This means that styles cannot be set and are immediately requested. You must allow IE to act on your manipulation as soon as your JavaScript completes the change. You can set a Timeout for 0 milliseconds that will hold the function call in any queue, and IE will make DOM changes before calling the next JavaScript bit.

+2
source

All Articles