SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Jun 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Issue with IE accesses document element attributes (like top and left co-ordinates) .

    I am creating a pop up bubble for a rollover effect on a page. This works fine in all browsers except IE.

    Here's the code....

    Code JavaScript:
     
                    var scrRoll = document.getElementById("scrollerRolloverText");
                    var el = document.getElementById("Technology");
     
                    top_value = el.y - 133;
                    scrRoll.style.top = top_value.toString() + "px";
                    scrRoll.style.left = el.x - 15 + "px";
                    scrRoll.innerHTML = item;
     
                    scrRoll.style.filter = "alpha(opacity=0);";
                    scrRoll.style.mozopacity = 0 / 100;
                    scrRoll.style.opacity = 0 / 100;
                    scrRoll.style.kthmlopacity = 0 / 100;
     
                    scrRoll.style.display = "block";
                    fader = setInterval(divFadeIn, 20);

    The issue that I appear to be facing is that IE cannot access the x an y co-ords of the element "Technology" (set to el in the above code). Any idea why IE can't access this attribute and the other browsers can? Any alternatives?

    Cheers,
    Ben

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quirksmode has some good info on how to find an elements position
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,861
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    I published a JavaScript object last week that provides all of those properties of elements in the web page that supports whatever browser is being used.

    See http://javascript.about.com/library/bldollarO.htm
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  4. #4
    SitePoint Member
    Join Date
    Jun 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the help guys. In the end I went with offsetX/offsetY (and a bit of maths magic) which appears is accessible by all current browsers.

    Cheers,
    Ben


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •