簡體   English   中英

該DIV未顯示在Internet Explorer上

[英]This DIV is not shown on Internet Explorer

我需要執行一些警報消息(例如驗證等),而我正在使用DIV進行此操作。

這就是我進行驗證的方式:

<form action="index.php" method="post" onsubmit="return validateSearchKeyword();">
        <input class="text_search" id="text_search" name="text_search" type="text" value="pesquisar" onfocus="if (this.value=='pesquisar') this.value = ''" onBlur="if (this.value=='') this.value = 'pesquisar'"  />
    </form> 

和驗證功能:

function validateSearchKeyword()
{
if (document.getElementById('text_search').value==""){creatediv('divAvisoPesquisa','You must supply a value', '355px', '125px');return false;}
}

這是創建DIV的功能:

function creatediv(id, html, left, top) {

if (document.getElementById(id)) 
    {
        //document.getElementById(id).style.display='block';
        //fadeIn(id, 300);
    }
    else
    {
        var newdiv = document.createElement('div');
        newdiv.setAttribute('id', id);
        newdiv.setAttribute("class", "warningDiv"); 
        newdiv.style.position = "absolute";
        newdiv.innerHTML = html;
        newdiv.style.left = left;
        newdiv.style.top = top;
        newdiv.style.display = "none";
        newdiv.onclick=function(e) {
            $(this).fadeOut(300, function() { $(this).remove(); });
        };  
        document.body.appendChild(newdiv);
        $("#"+id).fadeIn(300); 
    }
} 

fadInfadeOut函數來自“ jquery-1.3.1.min.js”

CSS ...

.warningDiv{
    -moz-border-radius-bottomleft:15px;
    -moz-border-radius-bottomright:15px;
    -moz-border-radius-topleft:15px;
    -moz-border-radius-topright:15px;
    font-size:11px;
    font-weight:bold;
    height:55px;
    padding:15px 25px;
    width:320px;
    z-index:100000;
    display: block;
}

因此,這對於Internet Explorer以外的所有瀏覽器都非常有效。 即使驗證有效(未通過驗證也不會提交表單),但不會顯示DIV。 我該如何解決?

謝謝

我想我明白了。 如果您使用IE,似乎無法正確應用類:

    newdiv.setAttribute("class", "warningDiv"); 

嘗試使用此代替:

    newdiv.className="warningDiv";

...我剛剛進行了測試,它在IE開發人員工具欄中顯示了所有正確的CSS屬性,而使用前者並沒有做到。

我幾乎可以確定JQuery的.fadeIn在IE6上不起作用。

嘗試不使用淡入淡出效果的函數,或將效果調用更改為:

$("#"+id).fadeIn(300,function() { $(this).show(); });

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM