【发布时间】:2010-10-08 09:00:30
【问题描述】:
我需要做一些警报消息(如验证等),我正在使用 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);
}
}
fadIn 和 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;
}
因此,这适用于所有浏览器,但 Internet Explorer 除外。即使验证有效(未通过验证时不提交表单),但未显示 DIV。 我该如何解决这个问题?
谢谢
【问题讨论】:
-
您能否更具体地提供 IE 版本?还是每个版本都会出现这种情况?
-
我正在用 IE 7 测试它
-
我只是想知道:z-index:100000 可能是造成这种情况的原因吗?
标签: javascript internet-explorer dom html