简体   繁体   English

如何在Firefox中使用Javascript设置DIV宽度/高度

[英]How to set DIV width/height with Javascript in Firefox

The following works in IE, but not Firefox: 以下适用于IE,但不适用于Firefox:

var el = $get('divToMask');
var box = Sys.UI.DomElement.getBounds(el);

var maskEl = $get('maskDiv');

// Only seems to work in IE
maskEl.style.width = box.width;
maskEl.style.height = box.height;

Sys.UI.DomElement.setLocation(maskEl, box.x, box.y);

box.width and box.height contain the correct values, but Firefox ignores the maskEl.style .width/.height methods. box.width和box.height包含正确的值,但Firefox忽略maskEl.style .width / .height方法。

Note: I'm not familiar with the Javascript helper library you are using. 注意:我不熟悉您正在使用的Javascript帮助程序库。

I'd guess that you need to change the two lines after your comment to the following: 我猜你需要在评论后更改两行:

maskEl.style.width = box.width + "px";
maskEl.style.height = box.height + "px";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM