2009-02-18 143 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(); });

相关问题