2009-02-18 89 views
0

我需要執行一些警報消息(如驗證等),我正在使用DIV執行此操作。此DIV未在Internet Explorer上顯示

這就是我正在做的驗證:

<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); 
    } 
} 

fadIn and fadeOut個功能是從 「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; 
} 

所以,這是對所有的瀏覽器除了IE偉大的工作。即使是驗證工作(表單在未通過驗證時也未提交),但未顯示DIV。 我該如何解決這個問題?

感謝

+0

你能更具體地提供IE版本嗎?還是每個版本都會發生? – RuudKok 2009-02-18 15:41:25

+0

我正在測試它與IE 7 – RSilva 2009-02-18 15:49:58

回答

3

我想我已經得到了它。看來,如果你使用IE不適類的正確方法:用

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

試試這個:

newdiv.className="warningDiv"; 

...我只是測試,它顯示了所有正確的CSS屬性IE開發者工具欄,它沒有使用前者。

1

我幾乎可以肯定JQuery的.fadeIn不能在IE6工作。

試試你的功能,而不淡入淡出效果或效果調用改成這樣:

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

相關問題