Sys$UI$DomElement$getLocation(element) causes javascript unspecified error

Last post 04-28-2008 9:02 PM by gchq. 5 replies.

Sort Posts:

  • Sys$UI$DomElement$getLocation(element) causes javascript unspecified error

    10-25-2006, 5:51 AM
    • Member
      12 point Member
    • Ludek Trefny
    • Member since 10-25-2006, 9:27 AM
    • Posts 3

    Hi,

    I've just implemented ASP.NET AJAX 1.0 beta and getting the javascript unspecified error in my web application (Atlas July build works fine). I'd debugged it and found following code causes the problem:

     
    1    Sys.UI.DomElement.getLocation = function Sys$UI$DomElement$getLocation(element) {
    2        /// <param name="element" type="Sys.UI.DomElement"></param>
    3        /// <returns></returns>
    4        var e = Function._validateParams(arguments, [
    5            {name: "element", type: Sys.UI.DomElement}
    6        ]);
    7        if (e) throw e;
    8    
    9        var offsetX = 0;
    10       var offsetY = 0;
    11       var parent;
    12   
    13       for (parent = element; parent; parent = parent.offsetParent) {
    14           if (parent.offsetLeft) {
    15               offsetX += parent.offsetLeft;
    16           }
    17           if (parent.offsetTop) {
    18               offsetY += parent.offsetTop;
    19           }
    20       }
    21   
    22       return { x: offsetX, y: offsetY };
    23   }
    
     
    parent = parent.offsetParent causes the uspecified error at line 13 where parent.offsetParent is null. 
    It might be fixed by function override in the page script. Maybe it helps someone with the same problem.
    Cheers
     `Ludek
  • Re: Sys$UI$DomElement$getLocation(element) causes javascript unspecified error

    10-27-2006, 5:12 PM
    • Member
      32 point Member
    • vitieubao
    • Member since 08-15-2006, 10:09 PM
    • Posts 7

    hi Ludek.

    I have the same problem but I am still using Atlas July build. the parent.offsetParent is null, how do you implement page script to override this method? can you explain more? I appreciate it.

    thanks.

  • Re: Sys$UI$DomElement$getLocation(element) causes javascript unspecified error

    10-29-2006, 5:32 PM
    • Member
      5 point Member
    • steve_vci
    • Member since 10-29-2006, 10:28 PM
    • Posts 1
    i get the same problem. the stack trace shows that ajax.net is attempting to handle an event invokation and reaches this point in order to get the location (x,y) of the dom element that raised the event. i can reproduce the error consistently but only for a single event in my application (so far) all other events work fine. for now, i just overrode the function with a try catch block around the for loop.
  • Re: Sys$UI$DomElement$getLocation(element) causes javascript unspecified error

    10-30-2006, 10:55 AM
    • Member
      12 point Member
    • Ludek Trefny
    • Member since 10-25-2006, 9:27 AM
    • Posts 3

    Just only put this javascript code into your page to fix it:  

    // ASP.NET AJAX fix
                Sys.UI.DomElement.getLocation = function(element) {     
                    /// <param name="element" type="Sys.UI.DomElement"></param>
                    /// <returns></returns>
                    var e = Function._validateParams(arguments, [
                        {name: "element", type: Sys.UI.DomElement}
                    ]);
                    if (e) throw e;
    
                    var offsetX = 0;
                    var offsetY = 0;
                    var parent;
                    try {
                        for (parent = element; parent; parent = parent.offsetParent) {
                            if (parent.offsetLeft) {
                                offsetX += parent.offsetLeft;
                            }
                            if (parent.offsetTop) {
                                offsetY += parent.offsetTop;
                            }
                        }
                    }
                    catch(ex) {}
    
                    return { x: offsetX, y: offsetY };
                    };
      
  • Re: Sys$UI$DomElement$getLocation(element) causes javascript unspecified error

    02-11-2008, 2:59 AM
    • Member
      2 point Member
    • yonishec
    • Member since 12-17-2007, 9:25 AM
    • Posts 4

    Hello,

    While working with ExtJs library and it's grid i had the same exception thrown from my JS code. In my scenario i have an image in my grid that by selecting it a column in the row that the image was click is changed and then changed back. When i set and change the data in my grid i got the same "unspecifed error" that was thrown from inside the getLocation method in line "var clientRects = element.getClientRects();"

    As i understand from other forums, the probvlem is that while i change the data in the grid, the grid is created again and when the ajax tries to validate the click event it does not find the image that i clicked on.

    After a while, i found this solution you give here to override the getLocation method. My prpblem is that when i insert this code to my page i get a new exception ""Sys.ArgumentTypeException: Object of type 'Object' cannot be converted to type 'Sys.UI.DomElement'.".

    For my own reason i added a "return" statment right after the starting body of the function.

    Is there any thing i'm doing wrong. Is there someother workaround to this problem. Is there any code i can supply that mught help someone understand my problem and mught help me????

    Thank yon,

    Joni.

  • Re: Sys$UI$DomElement$getLocation(element) causes javascript unspecified error

    04-28-2008, 9:02 PM
    • Member
      74 point Member
    • gchq
    • Member since 10-03-2007, 2:44 PM
    • Posts 101

    I'm having the same issue - an 'extender' div is created by clicking on the '+' icon and replaced with a '-' icon and the code blows out at 'var clientRects = element.getClientRects()' Does anyone have a way of overcoming this?

    Qui me amat, amet et canem meum
Page 1 of 1 (6 items)