Calling JavaScript after specific time?

Asked By 0 points N/A Posted on -

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?

Answered By 0 points N/A #92815

Calling JavaScript after specific time?


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.

<script type="text/javascript">
function timeMsg()
var t=setTimeout("alertMsg()",3000);
function alertMsg()

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

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

Login/Register to Answer

Related Questions