This project is archived and is in readonly mode.

#152 ✓wontfix
Ryan Mitchell

getCoordinates() returns incorrect value

Reported by Ryan Mitchell | June 21st, 2008 @ 10:15 PM | in 2.0 (closed)

getCoordinates returns the wrong value on ie7.

eg...

<!DOCTYPE html>

Untitled Document

window.addEvent('domready',function() {

alert($('blah').getCoordinates().top); // returns 0

});

sadsadsa

asdsaasdasdas

this should not alert 0, but it does!!

Comments and changes to this ticket

  • Ryan Mitchell

    Ryan Mitchell June 21st, 2008 @ 10:16 PM

    
    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Untitled Document</title>
    <script type="text/javascript" src="js/mootools.js"></script>
    <script type="text/javascript">
    window.addEvent('domready',function() {
    	
    	alert($('blah').getCoordinates().top); // returns 0
    									
    });
    </script>
    </head>
    
    <body>
    
    <form>
    <p><select id="blah">
    	<option value="sadsadsa">sadsadsa</option>
        <option value="asdsaasdasdas">asdsaasdasdas</option>
    </select></p>
    </form>
    
    </body>
    </html>
    
    

    code didnt output

  • batman42ca

    batman42ca July 1st, 2008 @ 09:33 PM

    On closer inspection, the difference seems to be that on IE6 it's necessary to add the margin from the tag to the left and right coordinate values whereas it appears to have already been taken into account in Firefox.

    So, it appears that getCoordinates() is not currently cross browser compatible.

  • Michael Duff

    Michael Duff July 14th, 2008 @ 04:33 PM

    The actual problem is from the getOffsets method. There is a "IE Only JavScript" method that solves this problem for us, so taking the current function and adding 1 line, problem seems to be solved. I have not done extensive testing.

    I added this to line 2195, right before the return of the getOffsets method:

    
    if (Browser.Engine.trident){ position.x = this.getBoundingClientRect().left; }
    
    

    Here is the info from MSDN

  • Ryan Mitchell

    Ryan Mitchell July 18th, 2008 @ 08:51 PM

    it was also returning an incorrect top value for me... so I would say you need to add:

    position.y = this.getBoundingClientRect().top;
    
  • Yuffster

    Yuffster July 19th, 2008 @ 05:48 PM

    • State changed from “new” to “hold”
    • Tag changed from 1.2, defect, ie to 1.2, blocker, critical, defect, ie
  • batman42ca

    batman42ca November 16th, 2008 @ 05:45 PM

    • Tag changed from 1.2, blocker, critical, defect, ie to defect, ie

    Another solution to my version of this problem is to set the position of the body to "relative". This then removes the problem with the margins since all coordinates will then be relative to the body, not to the upper left corner of the browser.

  • Christoph Pojer

    Christoph Pojer November 9th, 2010 @ 07:25 PM

    • State changed from “hold” to “wontfix”
    • Milestone order changed from “0” to “0”

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

Tags

Pages