繁体   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