弹出框自动关闭

时间:2014-03-20 09:51:19

标签: javascript html css

我需要在3秒内自动关闭弹出框。

请帮帮我们

HTML:

<div align="center">
<!--Validation Dialogue box popup-->
<div id="blanket" style="display:none;"></div>
<div id="validationPopup" style="display:none;">
</br>

<div id="validationMessage" align="center"></div>
</div>

<form id="Reject118" name="Reject118" method="post" action="#" onsubmit="return reject_validation(this.name);">
        <input type="submit" class="Reject" name="Reject" id="Reject" value="Reject" title="Click here to Reject this product item & send back for Moderator's Review" />
        <br />
        <textarea name="reject_reason" id="reject_reason" rows="3" cols="9" onblur="if(this.value == '')
{ this.value = 'Type Reject Reason Here';
this.style.color = '#8f8484';}" onfocus="if(this.value == 'Type Reject Reason Here'){ this.value = ''; this.style.color = '#8f8484';}" style="color:#8f8484;">Type Reject Reason Here</textarea>
</form>

我的FIDDLE

FIDDLE

4 个答案:

答案 0 :(得分:2)

我猜getElementById是弹出元素,在这种情况下,下面的JS应该可以工作:

setTimeout(function(){
   document.getElementById('validationPopup').style.display='none';
},3000)

答案 1 :(得分:0)

function Hidepopup() {
            document.getElementById('validationPopup').style.display = "none";
        }
        setTimeout("Hidepopup();", 3000);

答案 2 :(得分:0)

请添加以下代码

function hideautomatic {
  setTimeout(function () {

    setTimeout(function () {
        $("#yourpop").hide();

    }, 3000);
}, 1000);
};

答案 3 :(得分:0)

只需添加:

window.setTimeout(function() {
    toggle('blanket');
    toggle(windowname);
}, 3000);

到你的弹出窗口方法,这里是your fiddle