Is there a workaround for IE 6/7 “Unspecified Error” bug when accessing offsetParent

前端 未结 6 1913
一个人的身影
一个人的身影 2020-12-29 15:45

I\'m using jQuery UI\'s draggable and droppable libraries in a simple ASP.NET proof of concept application. This page uses the ASP.NET AJAX UpdatePanel to do partial page up

6条回答
  •  再見小時候
    2020-12-29 16:19

    This isn't just a jQuery error. I encountered it using ExtJS 4.0.2a on IE8. It seems that IE will almost always stumble on element.getBoundingClientRect() if the element has been replaced in the DOM. Your try/catch hack is pretty much the only way to get around this. I guess the actual solution would be to eventually drop IE < 9 support.

    Relevent ExtJS v4.0.2a Source Code (lines 11861-11869):

    ...
    if(el != bd){
        hasAbsolute = fly(el).isStyle("position", "absolute");
    
        if (el.getBoundingClientRect) {
            b = el.getBoundingClientRect();
            scroll = fly(document).getScroll();
            ret = [Math.round(b.left + scroll.left), Math.round(b.top + scroll.top)];
        } else {
    ...
    

    With a try/catch fix:

    ...
    if(el != bd){
        hasAbsolute = fly(el).isStyle("position", "absolute");
    
        if (el.getBoundingClientRect) {
            try {
                b = el.getBoundingClientRect();
                scroll = fly(document).getScroll();
                ret = [Math.round(b.left + scroll.left), Math.round(b.top + scroll.top)];
            } catch(e) {
                ret = [0,0];
            }
        } else {
    ...
    

提交回复
热议问题