我有一个自定义控件,它由一个文本字段和一个ajax控件工具包dateextender组成。在IE6中,我遇到了z-index错误,其中日历显示在选择框后面。
如果我将垫片放在控件中,最初是隐藏的,当显示日历时,它似乎显示正常,但是当我尝试动态创建垫片时,显示它不会出现。
我尝试过bgiframe和我在SO上找到的一些例子,没有运气。
这是我目前的javascript代码......
var dateEditorShim;
function dateEditor_OnShown(dateControl, emptyEventArgs) {
var shimWidth = dateControl._width;
var shimHeight = dateControl._height;
//var dateEditorShim;
//dateEditorShim = document.getElementById(dateEditorShimId);
dateEditorShim = document.createElement('iframe');
dateEditorShim.setAttribute('src', 'javascript:"";');
dateEditorShim.setAttribute('frameBorder', '0');
dateEditorShim.style.width = dateControl._popupDiv.offsetWidth;
dateEditorShim.style.height = dateControl._popupDiv.offsetHeight;
dateEditorShim.style.top = dateControl._popupDiv.style.top;
dateEditorShim.style.left = dateControl._popupDiv.style.left;
dateControl._popupDiv.style.zIndex = 999;
dateEditorShim.style.zIndex = 998;
dateEditorShim.style.display = "block";
}
function dateEditor_OnHiding(dateControl, emptyEventArgs) {
var shimWidth = 0;
var shimHeight = 0;
//var dateEditorShim;
//dateEditorShim = document.getElementById(dateEditorShimId);
dateEditorShim.style.width = 0;
dateEditorShim.style.height = 0;
dateEditorShim.style.top = 0;
dateEditorShim.style.left = 0;
dateEditorShim.style.display = "none";
}
你会注意到我有一个注释掉的代码来获取嵌入到页面中的iframe,正如我所说,在这种情况下iframe至少会显示出来,但是当我动态创建它时就像上面的代码一样目前,它没有。我想弄明白为什么。
有什么想法吗?
答案 0 :(得分:1)
好吧,我明白了。我只需要将元素附加到某个东西上。所以......
dateControl._container.appendChild(dateEditorShim);
诀窍。