我有一个脚本,可以在页面上弹出一个小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。知道这是怎么回事吗?我想我可能需要在过渡时期明确设定位置,但我不确定。
发布于 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,没有单位会引起问题。
发布于 2018-07-24 14:28:21
你可以使用:
document.getElementById("td").style.visibility="hidden";
document.getElementById("td").style.display="none";
而不是宽度属性。
它会起作用
https://stackoverflow.com/questions/-100000400
复制相似问题