iframe의 부모 창이 스크롤 할 때 iframe 내에서 modalpopup을 다시 센터하도록 도와주세요.

StackOverflow https://stackoverflow.com/questions/812876

문제

Iframe이있는 웹 페이지가 있습니다 (마음에 들지 않지만 그게 필요한 방식입니다). 그것은 크로스 도메인 이프 라메가 아니기 때문에 걱정할 것이 없습니다.

나는 modalpopup의 중심을 수행하는 jQuery 확장을 작성했습니다 (이는 재정의에서 불려집니다. ajaxcontroltoolkit.modalpopupbehavior._layout 방법) Iframe의 부모의 너비와 높이를 기준으로 Iframe이 페이지 중앙에 있지 않더라도 중심으로 보이도록 보입니다. 특히 웹 페이지가 iframe을 Quirks 모드로 추가했기 때문에 까다로운 것들이 많습니다.

이제 나는 또한 무시했습니다 ajaxcontroltoolkit.modalpopupbehavior._attachpopup, 부모 창이 크기를 조성하거나 스크롤 할 때, Iframe 최근의 모달 포 업은 부모 창의 새로운 크기와 관련하여 자체입니다. 그러나 팝업을 상위 창에 첨부하는 동일한 코드 크기를 조정하십시오 이벤트는 부모 창에 대해서는 작동하지 않습니다 스크롤 이벤트. 아래 코드와 의견을 참조하십시오.

AjaxControlToolkit.ModalPopupBehavior.prototype._attachPopup = function() {
    /// <summary>
    /// Attach the event handlers for the popup to the PARENT window
    /// </summary>
    if (this._DropShadow && !this._dropShadowBehavior) {
        this._dropShadowBehavior = $create(AjaxControlToolkit.DropShadowBehavior, {}, null, null, this._popupElement);
    }
    if (this._dragHandleElement && !this._dragBehavior) {
        this._dragBehavior = $create(AjaxControlToolkit.FloatingBehavior, {"handle" : this._dragHandleElement}, null, null, this._foregroundElement);
    }        
    $addHandler(parent.window, 'resize', this._resizeHandler); // <== This WORKS
    $addHandler(parent.window, 'scroll', this._scrollHandler); // <== This DOES NOT work
    this._windowHandlersAttached = true;
}

스크롤 이벤트가 그렇지 않은 동안 누구든지 크기 조정 이벤트가 작동하는 이유를 설명 할 수 있습니까? 나를 도와 줄 제안이나 대안이 있습니까? jQuery와 함께 작업하고 있으므로 MS의 $ addhandler 메소드 외에 무언가를 사용할 수 있다면 괜찮습니다. 핸들러를 제거하려면 _detachpopup 함수를 무시해야하므로이를 고려해야합니다.

감사!

도움이 되었습니까?

해결책

Nevermind, Quirks Mode를 다시 물었습니다. 문서 선택이 존재하지 않았기 때문에 부모로부터 스크롤 탑 위치를 얻는 것이 실패했습니다. 나는 전환했다

$(top.window.document.documentElement).scrollTop();

에게

$(top.window.document.body).scrollTop();

내 jQuery Extension Centering 코드에서 지금은 행복합니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top