جافا سكريبت style.width لا تعمل في فايرفوكس مع DOCTYPE الانتقالي

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

سؤال

ولدي السيناريو الذي ينعش وDIV صغيرة ظهرت على الصفحة. كل شيء يعمل بشكل جيد في IE، وفي FF إذا كنت إزالة DOCTYPE، ولكن عندما DOCTYPE هو XHTML / الانتقالي، في فايرفوكس، لا يغير العرض.

this.container.style.visibility = "visible";
alert("this.container.style.width before = " + this.container.style.width)
this.container.style.width = this.width;
alert("this.container.style.width after = " + this.container.style.width); 
this.container.style.height = this.height;

في IE، وفي FF مع عدم وجود DOCTYPE، التنبيه الأول يقول 0، والثاني يقول 320 (والذي هو عرض مجموعة في أي مكان آخر في كود)

وفي FF، مع DOCTYPE إلى XHTML / الانتقالية، سواء التنبيهات تظهر 0. أي فكرة عما يحدث هنا؟ أنا أفكر أنني قد تحتاج إلى تعيين صراحة المواقف على عناصر div في المرحلة الانتقالية، ولكن لست متأكدا.

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

المحلول

هل حاول الإعداد:

this.container.style.visibility = "visible";
alert("this.container.style.width before = " + this.container.style.width);
this.container.style.width = this.width + 'px';
alert("this.container.style.width after = " + this.container.style.width);
this.container.style.height = this.height + 'px';

//Note the 'px' above

وأجد أن تحاول وضع عرض / ارتفاع عدد، من دون وحدة يمكن أن يسبب مشاكل.

نصائح أخرى

ويمكنك استخدام:

document.getElementById("td").style.visibility="hidden";
document.getElementById("td").style.display="none";

وبدلا من خاصية العرض.

وكان يعمل!

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top