Wednesday, September 24, 2008

Strange document.body.clientWidth

If we use document.body.clientWidth directly like

a.left = (document.body.clientWidth - 800) /2

the result showed on browsers except IE (FF, Safari, Opera, Chrome) would be incorrect with no reason.

We need to use syntax like this

var cw = document.body.clientWidth;
a.left = (cw-800)/2;

and all browsers love it!

....Orz

No comments: