简体   繁体   中英

How to set DIV width/height with Javascript in Firefox

The following works in IE, but not 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.

Note: I'm not familiar with the Javascript helper library you are using.

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";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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