添加 1 到 z-index onclick 以兼容 IE
我正在使用 Raphael 制作一张地图。到目前为止,我的功能可以在 Chrome 和 Firefox 中运行,但是如何才能使其与 IE 兼容呢?这是我的测试地图的链接。 http://www.imsmfg.com/imsepracks/sales-reps.php
这是 JavaScript:
st[0].onclick = function () {
var maxZ = Math.max.apply(null,$.map($("#paper > *"), function(e,n){
if($(e).css("position")=="absolute")
return parseInt($(e).css("z-Index"))||1 ;
})
);
document.getElementById(current).style.display = "block";
document.getElementById(current).style.zIndex = maxZ+1;
current = state;
};
I'm putting together a map using Raphael. What I have so far works in Chrome and Firefox, but how can I make this compatible with IE? Here's a link to my test map. http://www.imsmfg.com/imsepracks/sales-reps.php
Here's the javascript:
st[0].onclick = function () {
var maxZ = Math.max.apply(null,$.map($("#paper > *"), function(e,n){
if($(e).css("position")=="absolute")
return parseInt($(e).css("z-Index"))||1 ;
})
);
document.getElementById(current).style.display = "block";
document.getElementById(current).style.zIndex = maxZ+1;
current = state;
};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我可以告诉你的一件事是,在 IE 中,在标记中出现较低的元素(但不是同一父元素的子元素)将始终具有较高的 z-index。
有两种可能的解决方案:
1) 重新编写代码,使其不依赖 z-index(
absolute
定位元素应始终出现在relative
或之上无论如何都是静态的)
2)物理移动文档正文底部的定位 div。
此外,您的 maxZ 计算看起来笨拙且混乱。您确定 max() 确实适用于任意值数组(即元素数量超过 2)吗?更具体地说,是在 IE 中。
如果您需要更多帮助,请发布您的标记。
One thing I can tell you is that in IE an element appearing lower in the markup (but not a child of the same parent) will always have higher z-index.
There are two possible solutions to that:
1) rework you code to not rely on z-index (
absolute
positioned elements should always appear over top of therelative
orstatic
ones anyway)2) physically move your positioned div at the bottom of the document body.
Also your
maxZ
calculations looks awkward and messy. Are you suremax()
actually works with arbitrary array of values (i.e. with number of elements more than 2)? In IE, more specifically.If you need more help, post your markup.
我在 IE8 上的 IE 控制台中收到错误:
对象不支持此属性或方法 - imsep.js 中的第 31 行
据我所知,问题在于设置 display:block;所以这可能与这个js错误有关。
编辑:
当我通过 ie dom 检查器手动设置显示块时,我看到了 div。
编辑2:
我在您的页面上找不到#accordion,您可能需要执行以下操作:
I get an error in my IE console on IE8:
Object doesn't support this property or method - line 31 in imsep.js
From what i have seen, the problem lies with setting display:block; so it might be related to this js error.
Edit:
When i set display block manually via the ie dom inspector, i see the div.
Edit2:
I don't find #accordion on your page, you may want to do something like: