Internet Explorer 7 のみでモーダル ウィンドウを表す div を表示するときに、ブラウザーのスクロール バーをロックする必要があります。グーグルで使用できることがわかりましたdocument.body.style.overflow='hidden'
が、これはIE7では機能しません。私もdocument.body.scroll="no"
どの作品で試してみましたが、スクロールバーの上にマウスを置いた後にのみ:-S
誰もがより良いアプローチを知っていますか?
ありがとう
Internet Explorer 7 のみでモーダル ウィンドウを表す div を表示するときに、ブラウザーのスクロール バーをロックする必要があります。グーグルで使用できることがわかりましたdocument.body.style.overflow='hidden'
が、これはIE7では機能しません。私もdocument.body.scroll="no"
どの作品で試してみましたが、スクロールバーの上にマウスを置いた後にのみ:-S
誰もがより良いアプローチを知っていますか?
ありがとう
さまざまな質問 (他のコメントを含む) に答えるために、間違ったポジショニング方法を使用していると思います。
試してみてくださいposition:fixed
。position:absolute
絶対ビューポートに相対的であることを除けば、基本的に同じです。つまり、ユーザーがスクロールすると、アイテムは画面上の同じ場所に留まります。
これを念頭に置いて、position:fixed
オーバーレイをレイアウトできます。その中には、モーダルボックスposition:absolute
(またはfixed
、必要に応じて、違いはありません) を含めることができます。
を使用してスクロールバーを非表示にすることもできるoverflow:hidden
ため、ユーザーはスクロールバーを表示しないため、スクロールしたくなることはありません:)
これはあなたを助けることができます:
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 : {}
}