2009-11-12 19 views
1

我有一個由文本字段和ajax控件工具包dateextender組成的自定義控件。在IE6中,我遇到了日曆顯示在選擇框後面的z-index錯誤。爲什麼非動態創建的iframe填充顯示,但動態創建的不是?

如果我有墊片坐在控制器中,最初隱藏起來,它顯示日曆時顯示正常,但當我試圖動態創建墊片顯示它沒有出現。

我試過bgiframe和我發現的一些例子,沒有運氣。

這是我目前的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至少顯示出來,但是當我像上面的代碼那樣動態創建它時,它不會。我試圖找出原因。

任何想法?

回答

1

嗯,我想通了。我只需要將元素附加到某個東西上。所以...

dateControl._container.appendChild(dateEditorShim); 

沒有訣竅。