Auto Close Pop up after some second (like alert not page) [Resolved]

Posted by Nksingh420 under JavaScript on 5/8/2014 | Points: 10 | Views : 20838 | Status : [Member] | Replies : 3
i have one form and after submission that page i want to show message box and redirect to other page.
when i use alert i have to click "ok".
is there any alternative with out alert box ?


Posted by: Allemahesh on: 5/8/2014 [Member] [MVP] Silver | Points: 50


Dear Singh,

I am relay happy to review my java-script and JQuery concept to answer this question.

Here I have used JQuery dialog and setTimeout() functions to achieve your requirement.
Just run the below code in visual studio and you will get you popup.

Here is the solution:-


<html xmlns="">
<head runat="server">
<title>jQuery UI Dialog - Default functionality</title>
<link rel="stylesheet" href="//">
<script src="//"></script>
<script src="//"></script>
<link rel="stylesheet" href="/resources/demos/style.css">

<script type="text/javascript" language="javascript">
function showAlert() {
setTimeout(TimeOut, 5000); //1000 ms = 1 second
function TimeOut() {
//window.location = "Your redirect URL";

<form id="form1" runat="server">
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" />
<div id="dialog" title="Alert" style="display: none;">
Set you message here.</p>


public partial class _Default : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)

protected void btnSubmit_Click(object sender, EventArgs e)
//Do you Insert logic.
ClientScript.RegisterStartupScript(typeof(Page), "Test", "<script type='text/javascript'>showAlert();</script>");

Happy Coding.

Nksingh420, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Chandradev819 on: 5/9/2014 [Member] Starter | Points: 25


You also refer this thread

Thanks and Regards
My Blog

Nksingh420, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sajjadhira on: 8/30/2017 [Member] Starter | Points: 25

This is an example of JavaScript automatic popup closing after 10 seconds with countdown,
<p style="text-align:center">This window will close automatically within <span id="counter">10</span> second(s).</p>
<script type="text/javascript">

function countdown() {

var i = document.getElementById('counter');

i.innerHTML = parseInt(i.innerHTML)-1;

if (parseInt(i.innerHTML)<=0) {




setInterval(function(){ countdown(); },1000);


I have found it in this . Hope this will be helpful for you.

Nksingh420, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response