I've come across a fairly obscure problem having to do with measuring a document's height before the styling has been applied by the browser. More information here:
- http://sonspring.com/journal/jquery-iframe-sizing
- http://ajaxian.com/archives/safari-3-onload-firing-and-bad-timing
In Dave Hyatt's comment from June 27, he advises simply checking the document.body.offsetLeft
property to force Safari to do a reflow.
Can I simply use the following statement:
document.body.offsetLeft;
or do I need to assign it to a variable, e.g.:
var force_layout = document.body.offsetLeft;
in order for browsers to calculate that value?
I think this comes down to a more fundamental question - that is, without being part of an assignment statement, will JavaScript still evaluate a property's value? Does this depend on whether a particular browser's JavaScript engine optimizes the code?