Calling JavaScript after specific time?

Asked By 0 points N/A Posted on -
qa-featured

I want to call JavaScript code from C# and I have used RegisterClientScriptBlock method to achieve this. Now, the problem is that I want this code to be executed on specific event after 5-10 seconds. I cannot catch that event again so I have to call this method on that event. How can I achieve this?

SHARE
Answered By 0 points N/A #92815

Calling JavaScript after specific time?

qa-featured

Set timing method in java script will done this job. So you need to set timing method. First user this method setTimeout() with returns a value. You have to set its parameter for timing. You can set parameter in seconds. Then write the program codes. I am giving an example. You have to use these codes at your own ways.

<html>
<head>
<script type="text/javascript">
function timeMsg()
{
var t=setTimeout("alertMsg()",3000);
}
function alertMsg()
{
alert("Hello");
}
</script>
</head>

<body>
<form>
<input type="button" value="Display alert box in 3 seconds"
onclick="timeMsg()" />
</form>
</body>
</html>

As a result after clicking the button the display box will come after 3 seconds.

Related Questions