4

Internet Explorer 7 のみでモーダル ウィンドウを表す div を表示するときに、ブラウザーのスクロール バーをロックする必要があります。グーグルで使用できることがわかりましたdocument.body.style.overflow='hidden'が、これはIE7では機能しません。私もdocument.body.scroll="no"どの作品で試してみましたが、スクロールバーの上にマウスを置いた後にのみ:-S

誰もがより良いアプローチを知っていますか?

ありがとう

4

4 に答える 4

13

さまざまな質問 (他のコメントを含む) に答えるために、間違ったポジショニング方法を使用していると思います。

試してみてくださいposition:fixedposition:absolute絶対ビューポートに相対的であることを除けば、基本的に同じです。つまり、ユーザーがスクロールすると、アイテムは画面上の同じ場所に留まります。

これを念頭に置いて、position:fixedオーバーレイをレイアウトできます。その中には、モーダルボックスposition:absolute(またはfixed、必要に応じて、違いはありません) を含めることができます。

于 2009-01-07T21:05:57.280 に答える
0

を使用してスクロールバーを非表示にすることもできるoverflow:hiddenため、ユーザーはスクロールバーを表示しないため、スクロールしたくなることはありません:)

于 2009-01-07T21:55:27.430 に答える
0

これはあなたを助けることができます:

documentOBJ = {
    /*Width and Height of the avaible viewport, what you'r seeing*/
    window : {
        x : function(){return (document.documentElement && document.documentElement.clientWidth) || window.innerWidth || self.innerWidth || document.body.clientWidth; },
        y : function(){return (document.documentElement && document.documentElement.clientHeight) || window.innerHeight || self.innerHeight || document.body.clientHeight;}
    },

    /*Scroll offset*/ 
    scroll : {
        x : function(){return ( document.documentElement && document.documentElement.scrollLeft) || window.pageXOffset || self.pageXOffset || document.body.scrollLeft; },
        y : function(){return ( document.documentElement && document.documentElement.scrollTop) || window.pageYOffset || self.pageYOffset || document.body.scrollTop; }
    },

    /*Height and width of the total of the xhtml in a page*/
    page : {
        x : function(){return (document.documentElement && document.documentElement.scrollWidth) ? document.documentElement.scrollWidth : (document.body.scrollWidth > document.body.offsetWidth) ? document.body.scrollWidth : document.body.offsetWidth; },
        y : function(){return (document.documentElement && document.documentElement.scrollHeight) ? document.documentElement.scrollHeight : (document.body.scrollHeight > document.body.offsetHeight) ? document.body.scrollHeight : document.body.offsetHeight; }
    },
    pointer : {}
}
于 2010-03-25T19:21:21.717 に答える