本帖最后由 newnewffzz 于 2012-11-02 16:44:18 编辑

解决方案 »

  1.   

    另外很神奇的是,我在另一个页面写的同样类似的代码却又正常.先贴代码:
    $('.newchilddiv').mouseover(function() {
                       //  $('#iframeViewTemplate').attr('src', '<%=Page.ResolveUrl("~/EditTemplate/ViewTempHtml.aspx")%>?time=' + new Date() + '&view=' + escape($(this).attr('mytext')));
                        $('#divViewTemplate').offset({ top: $(this).offset().top, left: ($(this).offset().left + $(this).width()) });
                      //  $('#iframeViewTemplate').css('width', '800');
                      //  $('#iframeViewTemplate').css('height', '300');
                    });
                    $('.newchilddiv').mouseout(function() {
                       // $('#iframeViewTemplate').attr('src', '#');
                       //  $('#iframeViewTemplate').css('width', '0');
                       // $('#iframeViewTemplate').css('height', '0');<div id="divViewTemplate" style="width: 0px; height: 0px; position: absolute;">fdsfds
            <iframe width="0" id="iframeViewTemplate" src="#"></iframe>
        </div>功能是用DIV重写了一个select,然后鼠标进入下拉框某项,一个隐藏DIV显示内容之类的.
    当然这段代码显示方式还没改,这样做很卡,且不讨论这个,问题是这个位置是正确的..能正常运行.我真看不出前面那个出问题的和这个的区别在哪.
      

  2.   

    好吧,一贴出来我就看到区别在哪了,把上面那个show和hide注释掉就正常了..
    现在解决方法是有了,用div.html('')代替hide.
    但是实在不甘心 hover show offset不能一起用,找到jquery包里关于show的这段也看不懂哪里动了位置.
    jquery-1.8.2.js 6577行,6634行show: function() {
    return showHide( this, true );
    },
    hide: function() {
    return showHide( this );
    },function showHide( elements, show ) {
    var elem, display,
    values = [],
    index = 0,
    length = elements.length; for ( ; index < length; index++ ) {
    elem = elements[ index ];
    if ( !elem.style ) {
    continue;
    }
    values[ index ] = jQuery._data( elem, "olddisplay" );
    if ( show ) {
    // Reset the inline display of this element to learn if it is
    // being hidden by cascaded rules or not
    if ( !values[ index ] && elem.style.display === "none" ) {
    elem.style.display = "";
    } // Set elements which have been overridden with display: none
    // in a stylesheet to whatever the default browser style is
    // for such an element
    if ( elem.style.display === "" && isHidden( elem ) ) {
    values[ index ] = jQuery._data( elem, "olddisplay", css_defaultDisplay(elem.nodeName) );
    }
    } else {
    display = curCSS( elem, "display" ); if ( !values[ index ] && display !== "none" ) {
    jQuery._data( elem, "olddisplay", display );
    }
    }
    } // Set the display of most of the elements in a second loop
    // to avoid the constant reflow
    for ( index = 0; index < length; index++ ) {
    elem = elements[ index ];
    if ( !elem.style ) {
    continue;
    }
    if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
    elem.style.display = show ? values[ index ] || "" : "none";
    }
    } return elements;
    }
      

  3.   

    感觉jquery的show方法该更新了,加个参数,传个控件进去,显示在控件旁边.
    前2天用的Dialog好歹还能传个坐标或者上下左右进去.
      

  4.   

    //返回的对象包含两个整型属性:top 和 left。此方法只对可见元素有效。
      

  5.   


    offset
    //返回的对象包含两个整型属性:top 和 left。此方法只对可见元素有效。
      

  6.   

    $('#divViewText').css({ top: $(this).offset().top, left: $(this).offset().left });
    试试