سؤال

وأحتاج لقفل التمرير المتصفح عندما تظهر شعبة التي تمثل إطار مشروط في Internet Explorer 7 فقط. غوغلينغ وجدت أنني يمكن استخدام document.body.style.overflow='hidden' ولكن هذا لا يعمل من أجل IE7. كما أنني حاولت مع document.body.scroll="no" الذي يعمل ولكن فقط بعد أن الماوس فوق شريط التمرير: -S

هل أحد يعرف aproach أفضل؟

وThansks

هل كانت مفيدة؟

المحلول

للرد على أسئلة مختلفة الخاص بك (بما في ذلك في تعليق الأخرى الخاصة بك)، وأعتقد أن كنت تستخدم طريقة تحديد الموقع الخطأ.

وحاول position:fixed. انها في الاساس نفس position:absolute بصرف النظر عن انها نسبة إلى العرض المطلق. أي: إذا كان تمرير المستخدم، هذا البند يبقى في نفس المكان على الشاشة

وحتى مع هذا في الاعتبار، يمكنك وضع تراكب position:fixed. ضمن أنه يمكن أن يكون position:absolute (أو fixed مرة أخرى، إذا كنت تفضل - أنه لا ينبغي أن تحدث فرقا) مربع مشروط

.

نصائح أخرى

وتعيين الخاص بك الوسائط شعبة تراكب لملء الجسم، لذلك حتى لو كانت التمرير لا يوجد شيء يمكن القيام به لأنه يتم إخفاء كل شيء تحته.

ويمكنك أيضا إخفاء أشرطة التمرير باستخدام overflow:hidden وبالتالي فإن المستخدم لن ترى scollbars لذلك لن يحصل يميل إلى scoll حول:)

وهذا يمكن أن تساعدك:

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 : {}
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top