dojo.marginBox 在 IE6 中返回错误的高度
我一直在尝试使用“dojo.marginBox”获取 DIV 的高度,但在 IE6 中我总是得到错误的高度。
这是我的代码的一部分:
<div id="outerDiv">
<div id="hiderDiv" class="hider"></div>
<div id="contentDiv1"></div>
<div id="contentDiv2"></div>
<div id="contentDiv3"></div>
</div>
“hiderDiv”的 CSS 看起来像这样:
position: absolute; background-color: grey; opacity: 0.5; z-index: 1000;
我期望它做的是这样的:三个 content-DIV 将动态填充一些内容,所以我不知道“的高度” outerDiv" 最终会是。 “innerDiv”应该阻止用户单击任何内容(同时仍然保持内容“灰显”但可见)。
由于内容高度在每个页面加载时动态变化,我尝试在加载所有内容后检索“outerDiv”的高度,然后将该高度应用于“hiderDiv”以覆盖所有内容:
dojo.style("hiderDiv", "height", dojo.marginBox("outerDiv").h + "px");
哪个有效,但是(惊讶!)不是在 IE6 中...
我检查了“marginBox”返回的高度,它在 IE6 中很高(实际上它覆盖了“outerDiv”的高度以及“outerDiv”之外的其他一些 DIV - 我不知道为什么会发生这种情况)。
我发现:如果我在填充 contentDivs 之前以编程方式将“outerDiv”的高度设置为“0px”(使用 dojo.style),它可以在 IE6 中工作,但在 FF 中,高度将保持 0px 并且之后不会更新内容已填满,因此弄乱了我的布局。
我不喜欢我的解决方法,这就是我写这篇文章的原因:
if (dojo.isIE == 6)
dojo.style("outerDiv", "height", "0px");
如果有人有不同的方法(除了“放弃 IE6 支持”:),我将不胜感激。
问候, 选择0r
I've been trying to get the height of a DIV using "dojo.marginBox", but I keep getting the wrong height in IE6.
Here's part of my code:
<div id="outerDiv">
<div id="hiderDiv" class="hider"></div>
<div id="contentDiv1"></div>
<div id="contentDiv2"></div>
<div id="contentDiv3"></div>
</div>
The CSS for the "hiderDiv" looks something like this:
position: absolute; background-color: grey; opacity: 0.5; z-index: 1000;
What I expect it to do is this: the three content-DIVs will be filled dynamically with some content, so I don't know which height the "outerDiv" will end up with.
The "innerDiv" is supposed to prevent users to click on any of the content (while still keeping the content "greyed out" but visible).
As the content-height changes dynamically on each page-load, I tried to retrieve the height of "outerDiv" after all content has been loaded and then apply that height to "hiderDiv" to cover all of the content:
dojo.style("hiderDiv", "height", dojo.marginBox("outerDiv").h + "px");
Which works, but (surprise!) not in IE6 ...
I checked the height which is returned by "marginBox" and it's way to high in IE6 (in fact it covers the height of "outerDiv" plus some other DIV that's outside of "outerDiv" - I have no idea, why that happens).
What I found out: if I set the height of "outerDiv" to "0px" programmatically (using dojo.style) before filling the contentDivs, it works in IE6, but in FF the height will just stay 0px and won't update after the content has been filled and so messing up my layout.
My workaround, that I don't like, that's why I'm writing this post:
if (dojo.isIE == 6)
dojo.style("outerDiv", "height", "0px");
If anybody has a different approach (apart from "drop IE6-support" :), I'd appreciate it.
Greetings,
Select0r
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,由于这个问题一年多以来没有受到任何关注,我将接受我的解决方法作为答案:)
Well, as this question didn't receive any attention for more than a year now, I'll accept my workaround as the answer :)