Javascript Internet Explorer上未显示此DIV
我需要做一些警告消息(比如验证等),我正在用DIV做这件事 我是这样做验证的:Javascript Internet Explorer上未显示此DIV,javascript,internet-explorer,dom,html,Javascript,Internet Explorer,Dom,Html,我需要做一些警告消息(比如验证等),我正在用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
<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>
这是创建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。
我怎样才能解决这个问题
谢谢我几乎可以肯定JQuery的
.fadeIn
在IE6上不起作用
尝试不带淡入淡出效果的功能,或将效果调用更改为:
$(“#”+id).fadeIn(300,function(){$(this.show();})代码>我几乎可以肯定JQuery的.fadeIn
在IE6上不起作用
尝试不带淡入淡出效果的功能,或将效果调用更改为:
$(“#”+id).fadeIn(300,function(){$(this.show();})代码>我想我知道了。如果您使用以下选项,IE似乎没有以正确的方式应用类:
newdiv.setAttribute("class", "warningDiv");
请尝试使用此选项:
newdiv.className="warningDiv";
。。。我刚刚测试过,它在IE开发者工具栏中显示了所有正确的CSS属性,而不是使用前者。我想我已经找到了。如果您使用以下选项,IE似乎没有以正确的方式应用类:
newdiv.setAttribute("class", "warningDiv");
请尝试使用此选项:
newdiv.className="warningDiv";
。。。我刚刚测试过,它在IE开发者工具栏中显示了所有正确的CSS属性,而不是使用前者。您能更具体地提供IE版本吗?还是每个版本都会出现这种情况?我正在用IE 7测试它。我只是想知道:z-index:100000可能是导致这种情况的原因吗?你能更具体地提供IE版本吗?还是每个版本都会出现这种情况?我正在用IE 7测试它。我只是想知道:z-index:100000可能是导致这种情况的原因吗?我尝试过不使用fadeIn,并且注释了display=“none”;但是DIV没有显示出来。但是我安装了IEDeveloperToolbar,并且创建了div,但是不可见,我只是不知道为什么。Thanks@Armadillo:根据IE工具栏,元素是否具有正确的样式?显示:块、视图中的位置、大z索引等?@Adam Bellaire:否。。。这就是样式行显示的内容:“左:120px;位置:绝对;顶:250px”|没有z索引、块等。奇怪:|@Armadillo:它在这里按预期工作。确保有一个DOCTYPE集,否则IE将在怪癖模式下呈现您的页面(我建议您使用XHTML)。此外,请检查应用于该div的CSS。DOCTYPE已定义。我会尽力搞乱CSS。谢谢,我尝试过不使用fadeIn,并在显示中注释了“无”;但是DIV没有显示出来。但是我安装了IEDeveloperToolbar,并且创建了div,但是不可见,我只是不知道为什么。Thanks@Armadillo:根据IE工具栏,元素是否具有正确的样式?显示:块、视图中的位置、大z索引等?@Adam Bellaire:否。。。这就是样式行显示的内容:“左:120px;位置:绝对;顶:250px”|没有z索引、块等。奇怪:|@Armadillo:它在这里按预期工作。确保有一个DOCTYPE集,否则IE将在怪癖模式下呈现您的页面(我建议您使用XHTML)。此外,请检查应用于该div的CSS。DOCTYPE已定义。我会尽力搞乱CSS。非常感谢。