Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery position problem with Chrome

Tags:

When I alert the value .position().left, it returns 0 on Chrome. With other browsers it returns the actual number. Why does this happen?

like image 351
goksel Avatar asked Jan 31 '10 19:01

goksel


1 Answers

Webkit based browsers (like Chrome and Safari) can access images width and height properties only after images have been fully loaded. Other browsers can access this information as soon as just the DOM is loaded (they don't need to load the images entirely to know their size).

So, if you have images in your page, with Webkit based browsers you should access offset information after the $(window).load event fires, and not after the $(document).ready event.

like image 109
Luca Fagioli Avatar answered Sep 24 '22 02:09

Luca Fagioli