首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >为什么javascript style.width无法在firefox中使用过渡doctype?

为什么javascript style.width无法在firefox中使用过渡doctype?
EN

Stack Overflow用户
提问于 2018-07-24 04:39:50
回答 2查看 0关注 0票数 0

我有一个脚本,可以在页面上弹出一个小DIV。这一切在IE中工作正常。在FF中,如果我删除DOCTYPE,当DOCTYPE是XHTML / Transitional时,在Firefox中,宽度不会改变了。

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中,在没有DOCTYPE的FF中,第一个弹窗为0,第二个弹出为320(这是代码中其他地方设置的宽度)。

在FF中,通过DOCTYPE到XHTML/过渡期,两个弹窗都显示为0。知道这是怎么回事吗?我想我可能需要在过渡时期明确设定位置,但我不确定。

EN

回答 2

Stack Overflow用户

发布于 2018-07-24 12:53:02

你试过设置:

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

我发现,试图设置一个数字的width/height,没有单位会引起问题。

票数 0
EN

Stack Overflow用户

发布于 2018-07-24 14:28:21

你可以使用:

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

而不是宽度属性。

它会起作用

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/-100000400

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档