Hello,
Can anyone please tell me what is the difference between left and pixelLeft in the style propertie ?
Thanks![]()
Hello,
Can anyone please tell me what is the difference between left and pixelLeft in the style propertie ?
Thanks![]()
The main differences I can think of are:
- pixelLeft is proprietary to some (possibly only IE) browsers.
- pixelLeft isn't a style, it is a javascript setter/getter property of an element's style.
- pixelLeft assumes pixels as units and is an integer.
- left is used by virtually all browsers and to work generally (but not always) requires that the units be specified (left:20px; or left:10%; etc.)
- left is a style property as well as a javascript setter/getter property of an element's style. It is a string not an integer.
See also:
http://msdn.microsoft.com/workshop/a.../pixelleft.asp
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
So technically left and pixelleft are same apart from above differences ?
Pretty much but, the differences are significant. Since everything that can be accomplished with pixelLeft can be done with left and/or other cross browser techniques and, left works in all browsers, I'd just forget about pixelLeft unless it came in handy for something that needed to be IE only and didn't cause other problems.
BTW - This works in IE 7, Opera 9.01 but, not in FF:
HTML Code:<div style="position:relative;left:10px;" onclick="alert(this.style.pixelLeft);">Hi</div>
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
Thanks for your help!
It would be a good idea to use [object].offsetLeft instead. Or parseInt([object].style.left).
- Mike
Bookmarks